<?xml version="1.0" encoding="UTF-8"?>
<Export generator="Cache" version="25" zv="Cache for Windows (x86-32) 2012.2 (Build 638U)" ts="2013-07-09 06:54:47">
<Class name="AGMPI.Adapters.HLOGlobalInbound">
<IncludeCode>EnsHL7</IncludeCode>
<Super>Ens.InboundAdapter</Super>
<TimeChanged>62997,34324.7265</TimeChanged>
<TimeCreated>61592,31859.341221</TimeCreated>

<Property name="ReceivingFacilityName">
<Description>
Name of the Receiving Facility to filter HL7 messages.</Description>
<Type>%String</Type>
<Parameter name="MAXLEN" value="200"/>
</Property>

<Property name="MaxNmbrMsgs">
<Description>
Maximum number of messages to retrieve/send per poll/task. </Description>
<Type>%Integer</Type>
</Property>

<Property name="Throttle">
<Description>
Time to hang before processing another message,
used to manage the throughput.</Description>
<Type>%Integer</Type>
</Property>

<Property name="NmbrMsgsSnt">
<Description>
The number of messages retrieved.</Description>
<Type>%Integer</Type>
</Property>

<Property name="AInfo">
<Description>
Information to send an alert from the business service
 if populated.</Description>
<Type>%String</Type>
</Property>

<Property name="SiteID">
<Description>
Site ID.  This is the STATION NUMBER</Description>
<Type>%String</Type>
</Property>

<Parameter name="SETTINGS">
<Type>%String</Type>
<Default>ReceivingFacilityName, MaxNmbrMsgs, Throttle, SiteID</Default>
</Parameter>

<Method name="OnTask">
<ReturnType>%Status</ReturnType>
<Implementation><![CDATA[
  set $ZT="Trap", tSC=$$$OK

  // Initialize a start time variable.
  set tStartTime = $P($H,",",2)	
  // Initialize the Alert Information property to the null string.
  set ..AInfo=""
  // Initialize the number of messages sent during this connection.
  set ..NmbrMsgsSnt=0
  // Initialize a variable(Flag) to use to quit when we reach the maximum
  // number of messages.
  set tQuitAll=0
  // Set the field delimiter for the HLB data set.
  set U = "^"
  // Set the initial HLB index value to zero.
  set tIENB=0
  // Set the ^HLB QUEUE Node index variables.
  set tQueue="", tLink=""
  
  // Indices of the HLB queue are;
  // the string "QUEUE"
  // the string "OUT"
  // the HLO Logical Link and Port associated with it
  // the Queue Type
  // ^HLB("QUEUE","OUT",tLink,tQueue,tIENB)

  // Outer loop going through the tLink values   
  do { 
	  // If the ReceivingFacilityName variable is not set we will not process any
	  //  messages.
	  if (""=..ReceivingFacilityName) {
		  set ..AInfo=..AInfo_" No Receiving Facility Name is set for the Inbound HLO Global Adapter, no messages are being processed." 
  	  	  do ..BusinessHost.SendAlert(##Class(Ens.AlertRequest).%New($LB(..BusinessHost.%ConfigName,"ERROR in Configuration", ..AInfo)))
		  quit //exit the do loop
  	  }

	  // Get the tLink index
	  set tLink = $O(^HLB("QUEUE","OUT",tLink))
	
	  // If the tLink variable is null we do not have any more nodes to process
	  if (tLink="") { quit }
	  
	  // Loop through the tQueue values at the tLink index
	  for {
		  // Get the tQueue index
		  set tQueue = $O(^HLB("QUEUE","OUT",tLink,tQueue))
	  
		  // If the tQueue variable is null we do not have any more nodes at this level to process.
		  if (tQueue="") { quit }
	  
		  //Loop through the IENs at the tLink.tQueue index
		  for {
			  // Get the tIENB index
			  set tIENB = $O(^HLB("QUEUE","OUT",tLink,tQueue,tIENB))
	  
			  // If the TIENB varible is zero we do not have an IEN to process
			  if (tIENB="") { quit }
	  
			  // Initialize the Node Data variable.
			  set tNodeData = ""
	  
			  // if there's no data within the node we skip this entry and go to the next
			  if '($D(^HLB(tIENB,0),tNodeData)#10) { continue }
	        
			  // Get the message direction from the Node Data
			  set tMessageDirection=$ZCONVERT($p(tNodeData,U,4),"U")
	  
			  // If the direction is not outbound we skip this entry and go to the next
			  if '(tMessageDirection = "O") { continue }
	  
			  // Get the date processed from the Node Data
			  set tDateProcessed=$p(tNodeData,U,16)
	  
			  // If the Date Processed is not empty, this message has already been processed, we
			  //  skip this entry and go to the next
			  if '(tDateProcessed="") { continue }
	  
			  // Get the A index 'tIENA' from the Node Data.
			  set tIENA=$p(tNodeData,U,2)
	  
			  // Get the MSH segment from the HLB tIENB.1 and tIENB.2 node entries
			  set tMSHsegment=$G(^HLB(tIENB,1))_$G(^HLB(tIENB,2)) 

              // Reset the Field Separator variable to the empty string before 
              //  reading the value from the current MSH segment
              set tFieldSeparator=""
         
			  // The field separator is the 4th character of the MSH segment.
			  set tFieldSeparator=$E(tMSHsegment,4)
			  
			  // If the field separator is missing we exit the loop
			  if (tFieldSeparator="") {continue}
			  
			  // Reset the Copmponent Separator value to the empty string before 
			  //  reading the value from the current MSH segment
              set tComponentSeparator=""
			  
			  // The component separator is the 5th character of the MSH segment.
			  set tComponentSeparator=$E(tMSHsegment,5)
			  
			  // If the component separator is missing we exit the loop
			  if (tComponentSeparator="") {continue}

              // Reset the Message Type variable to the empty string before 
              //  reading the value from the current MSH segment
              set tMessageType=""

			  // Get the Message Type
			  set tMessageType=$P(tMSHsegment,tFieldSeparator,9)
			  
			  // If the Message Type is missing we exit the loop
			  if (tMessageType="") {continue}
 	  
			  // We set the MessageType field to the MessageCode and Trigger Event subfields.
			  set $p(tMSHsegment,tFieldSeparator,9) = $p(tMessageType,tComponentSeparator,1,2)
 	  
			  // Get the segment name wthin the MSH segment, if we do not have a field separator
			  //  we cannot get the segment name
			  set tSegmentName = $p(tMSHsegment,tFieldSeparator,1)
 	  
			  // If we do not have a MSH segment we do not process this message
			  if '(tSegmentName = "MSH") { continue }

			  // If the receiving facility of the message doesn't match the ReceivingFacility 
			  //  in the parameter, we do not process this message.
			  if '(..ReceivingFacilityName=$p(tMSHsegment,tFieldSeparator,5)) { continue }

			  // -------------------------------------------------------------------------
			  // We've identified a message that should be sent to the receiving facility
			  // Build the HL7 message to send to the RPMS Service
	  
			  // Set the segment separator
			  set tSegmentSeparator=$c(13)
	        
			  // Add the MSH segment to the text string
			  set tMessageText=tMSHsegment_tSegmentSeparator
            
			  // Set the segment index to zero
			  set tSegmentIndex=0
      
			  // Set the segment data to the null sting to begin with
			  set tSegmentData=""
			  set tSegmentData2=""


			  // Loop through the ^HLA indicies for the message segments.
			  for tSegmentIndex=1:2{
				  // Set the tSegData variable
				  set tSegmentData= $G(^HLA(tIENA,1,tSegmentIndex,0))
				  // If the length of data is zero we quit the for loop
				  if ($L(tSegmentData)=0) { quit }
				  set tSegmentData2=$G(^HLA(tIENA,1,tSegmentIndex+1,0))
				  set tMessageText=tMessageText_tSegmentData_tSegmentData2_tSegmentSeparator					  
			  }	

			  TStart

			  // Create the HL7 message document to send to the business 
			  //  host that will route the message
			  set tHL7obj=##class(EnsLib.HL7.Message).ImportFromString(tMessageText)
            
			  // Check to see that the hl7obj is an object
			  set tObjectError= $ISOBJECT(tHL7obj)
	  
			  // Send a message to the ENS.Alert Process if we fail to create an object to send
			  If 'tObjectError {
				  set tSC=%objlasterror
				  set ..AInfo=" Failed to create an HL7 message with the information retrieved from the HLA global, IEN= "_tIENA
				  set ..AInfo=..AInfo_" ERROR:= "_##class(%SYSTEM.Status).GetErrorText(tSC)
				  do ..BusinessHost.SendAlert(##Class(Ens.AlertRequest).%New($LB(..BusinessHost.%ConfigName,"There was an issue creating a valid HL7 message in the HLOGlobalInbound Adapter: ", ..AInfo)))
				  set ..AInfo=""
				  tRollBack
				  continue
			  }
			
			  // Send the message to the Business Host  
			  set tBusinessHostResponse=..BusinessHost.ProcessInput(tHL7obj)
			  
			  // Increase the number of messages we've sent this period
			  set ..NmbrMsgsSnt=..NmbrMsgsSnt+1
			  
			  // If we sent a message to the production,we need to update the 16th field within
			  //  the HLB global with the Fileman date.
			  set $p(^HLB(tIENB,0),U,16)=..GetFilemanDateTime(0) 
	  
			  // Remove the ^HLB("QUEUE","OUT",tLink,tQueue,tIENB) entry
			  kill ^HLB("QUEUE","OUT",tLink,tQueue,tIENB)
	  
			  // decrement the HLC counter, if it exist
			  if (+$G(^HLC("QUEUECOUNT","OUT",tLink,tQueue))) {
				  set tTemp = $i(^HLC("QUEUECOUNT","OUT",tLink,tQueue),-1) 
			  }
			
			   TCommit
			  If ( ..NmbrMsgsSnt =..MaxNmbrMsgs)  {
				  set tQuitAll=1
				  quit
			  }
			  // Set the Current Time variable
			  set tCurrentTime = $P($H,",",2)
			  // Set the processing time, if the start time is greater than the
			  //  current time (we passed midnight) and will always set the 
			  //  processing time to a value greater than the call interval. 
			  If tStartTime > tCurrentTime {
				  set tProcessingTime = tStartTime - tCurrentTime
			  }
			  else {
				  set tProcessingTime = tCurrentTime - tStartTime
			  }
			  // If the processing time is greater than the Call Interval
			  //  return control to the Service that called the adapter.
			  if (tProcessingTime > ..CallInterval) {
				  set tQuitAll=1
				  quit
			  }
			  HANG (..Throttle/1000)
			  if (tQuitAll) {quit}
		  } // Close the IEN loop
		  if tQuitAll {quit}
	  } // Close the tQueue loop
  }While '(tQuitAll) // Close the tLink loop
  quit $$$OK

Trap
	// We erred out, set the error information and roll back the last transaction.
	set $ZT=""
	TRollback
	set tSC=$$$EnsSystemError
	do ..BusinessHost.SendAlert(##Class(Ens.AlertRequest).%New($LB(..BusinessHost.%ConfigName,"There was an error in the HLOGlobalInbound Adapter: ", tSC)))
	quit $$$OK
]]></Implementation>
</Method>

<Method name="GetFilemanDateTime">
<Description>
Returns the date/time in FileManFormat</Description>
<ClassMethod>1</ClassMethod>
<FormalSpec>pDays:%Integer=0</FormalSpec>
<ReturnType>%String</ReturnType>
<Implementation><![CDATA[
	set tCurrentDateTime = $H
	set $P(tCurrentDateTime,",",1)=$P(tCurrentDateTime,",",1)+pDays
	set tFileManDate = ($ZDATETIME(tCurrentDateTime,8,1,9)-17000000)
	set tCurrentTime = $P(tCurrentDateTime,",",2)
	set tCurrentTimeFormatted = $ZTIME(tCurrentTime,2)
	set tFileManTime = $P(tCurrentTimeFormatted,":",1)_$P(tCurrentTimeFormatted,":",2)
	quit (tFileManDate_"."_tFileManTime)
]]></Implementation>
</Method>
</Class>


<Class name="AGMPI.Adapters.HLOGlobalOutbound">
<ClassType/>
<IncludeCode>EnsHL7</IncludeCode>
<IncludeGenerator>EnsHL7</IncludeGenerator>
<ProcedureBlock>1</ProcedureBlock>
<Super>Ens.OutboundAdapter</Super>
<TimeChanged>63008,47350.563731</TimeChanged>
<TimeCreated>62942,27311.051119</TimeCreated>

<Property name="SiteID">
<Description>
Facility number.</Description>
<Type>%String</Type>
</Property>

<Property name="LLink">
<Description>
Logical Link between the two systems (i.e. Den-RPMS)</Description>
<Type>%String</Type>
</Property>

<Parameter name="SETTINGS">
<Type>%String</Type>
<Default>SiteID, LLink</Default>
</Parameter>

<Method name="FileMessage">
<FormalSpec>InboundMsg:EnsLib.HL7.Message</FormalSpec>
<ReturnType>%Status</ReturnType>
<Implementation><![CDATA[
	set $ZT="Trap", tSC=$$$OK
	// set the A and B node indexes  to null.
	set tIENA="", tIENB=""
	// set the field delimiter for the HLB/HLA data set.
	set U = "^"
	// set a variable flag that will tell us if there were errors
	//  encountered while attempting to update or set the HLA or HLB
	//  global nodes.  Used to either commit or roleback the changes
	//  and to populate the alert content.
	set tError = 0
	set tText = ""
	TStart
    
	Do {
		if ..SiteID=""  {
			set tError=1
			set tText="Failure: The SiteID Property is not set within the HLOGlobalOutbound adapter, no messages are being processed."
			quit
		}

		// Temp variable to hold the inbound message ID.
		set tIncomingMessageId=InboundMsg.%Id()
		// Temp variable to hold the number of segments within the message.
		set tSegmentCount=InboundMsg.SegCountGet()
		// Temp variable to hold the message separators.
		set tMessageSeparators=InboundMsg.Separators
		// Temp variable to hold the segment field separator.
		set tFieldSeparator= InboundMsg.FS
		// Temp variable to hold the sub-component separator.
		set tComponentSeparator= InboundMsg.CS
		// Temp variable to hold the MSH segment, it's always the 
		//  first segment of an HL7 message.
		set tMSHsegment=InboundMsg.GetValueAt(1)
  		// Temp variable to hold the incoming message control ID.
 		set tIncomingMessageControlId= $P(tMSHsegment,tFieldSeparator,10)
		// Temp variable to hold the HL7 Trigger Event.  The second component within
		//  the 9th field of the MSH segment.
		set tTriggerEvent=$P($P(tMSHsegment,tFieldSeparator,9),tComponentSeparator,2)
		// Temp variable to hold the HL7 Message Code.  The first component within
		//  the 9th field of the MSH segment.
		set tMessageCode=$P($P(tMSHsegment,tFieldSeparator,9),tComponentSeparator,1)
		// Temp variable to hold the sending facility.  The 5th field of the MSH segment.
		// field 5 is actually the Receiving application.
		set tReceivingApplication=$P(tMSHsegment,tFieldSeparator,5)
        // Temp variable to hold the MSA segment, it is the second
        //  segment within an incoming ACK message
		set tMSAsegment=InboundMsg.GetValueAt(2) 
 		// Temp variable to hold the Acknoledgment Code
 		set tAcknowledgmentCode = $P(tMSAsegment,tFieldSeparator,2)
 		// Temp variable to hold the Sending Application
 		set tSendingApplication=$p(tMSHsegment,tFieldSeparator,3)

     
   //--------------------Start of updating the HLB entries for an ACK
   
		// If the message class is an ACK it is a response to
		//  a sent message we sent and will update the HLB global
		//  using the IEN from the 'B' CrossReference sub Control ID .
		if (tMessageCode="ACK") { 
 			// Get the MessageControlID from the MSA segment
			set tMessageControlId = $P(tMSAsegment,tFieldSeparator,3)
			// If there isn't a MessageControlID we set the error text 
			//  and exit the loop.
			if (tMessageControlId = "") {
				set tError=1
				set tText="Failure: The HLOGlobalOutbound adapter failed to Process ACK Message "_tIncomingMessageId_",  because it does not contain a Message Control ID"
				quit
			}
			// Get the tIEN from the 'B' Crossreference.
			set tIEN= $O(^HLB("B",tMessageControlId,""))
			// If the tIEN is blank we add a space to the tMessageControlId and then
			//  try to obtain the tIEN again.
			If (tIEN="") {set tIEN=$O(^HLB("B"," "_tMessageControlId,""))}
 			// IF there isn't a IEN from the 'B' Crossreference then we set the 
 			//  error text and exit the loop.
			if (tIEN="") {
				set tError=1
				set tText="Failure: The HLOGlobalOutound adapter failed to Process Message "_tIncomingMessageId_" (an ACK) because the 'B' reference node did not exist for Message Control ID "_tMessageControlId
				quit
			}
	  		// If the acknowledgment code is application accept
			if (tAcknowledgmentCode="AA"){
				// set the Accept Acknowledgment field (17) of the zero node.
				set $P(^HLB(tIEN,0),U,17)=1  
				//  Get the current Date/Time in FileMan format.
				set tCurrentDate=..GetFilemanDateTime(0)
				// set the Acknowledge Date field (1) of the 4th node.
				set $P(^HLB(tIEN,4),U,1)=tCurrentDate
				// set the Acknowledge Message ID field (2) of the 4th node.
				set $P(^HLB(tIEN,4),U,2)=tIncomingMessageControlId 
				 
				// set the ACCEPT ACK MSA SEGMENT field (3) of the 4th node.
				set $P(^HLB(tIEN,4),U,3)=$p(tMSAsegment,tFieldSeparator,1,3) 
				 
            // If the acknowledgment code is not an application accept and it is
            //  not a comit acknoledgment it is considered an application error.
			} 
			elseif '(tAcknowledgmentCode ="CA") {
				// set the message status field (20) of the zero node to AE.
				set $p(^HLB(tIEN,0),U,20)= "AE" 
				 
				// If the # of segments are greater than 2 then we have an ERR segment 
				//  to pull information from.
				if (tSegmentCount > 2) {
					set tERRsegment=InboundMsg.GetValueAt(3)
			        set $p(^HLB(tIEN,0),U,21)= $E(tERRsegment,5,34)
		        }
		        else {
			        set $p(^HLB(tIEN,0),U,21)= tIncomingMessageControlId
		        }
		        
				// If the link field (5) of the zero node and the transmission date 
				//  field (16) of the zero node are not blank then we need to create an
				//  ERROR entry in the HLB global.
				If ($p(^HLB(tIEN,0),U,5)'="")&&($p(^HLB(tIEN,0),U,16)'="") {
					set ^HLB("ERRORS","AE",$p(^HLB(tIEN,0),U,5),$p(^HLB(tIEN,0),U,16),tIEN)=""
				}
		       	set tText="Alert: The HLOGlobalOutound adapter received message "_tIncomingMessageId_" (an ACK message) that did not contain an 'AA' or 'CA' Acknowledgment Code: The MessageControl ID is "_tMessageControlId
			}
	  

  	
		} 
   	// -----------------End of updating the HLB entries for an ACK
		// If the message code is of type ACK or MFN, we have a message that needs 
		//  to be added to the HLA/HLB global nodes
		if ((tMessageCode="ACK") || (tMessageCode="MFN")) { 
			set tIENB=..GetNewIENB()
 			// If the HLB index returned is zero , we do not have an index to use 
 			//  for the HLB global node.  set the error text and exit the loop
			if 'tIENB {
			    set tError=1
			    set tText="Failure: The HLOGlobalOutbound adapter was unable to obtain an unused IEN for ^HLB"
				quit
			}
			
			set tIENA=..GetNewIENA()
 			// if the HLA index returned is zero, we do not have an index to use
 			//  for the HLA global node . set the error text and exit the loop
			if 'tIENA {
				set tError=1
				set tText="Failure: The HLOGlobalOutbound adapter was unable to obtain an unused IEN for ^HLA"
				quit
			}
	  	
			// save the information into the HLB global.
			
			// set the Control ID (SitID parameter_Space_HLB IEN).
			set tControlId=..SiteID_" "_tIENB
			// set the tIENB.zero node to the the null string.
			set ^HLB(tIENB,0)=""
			// set the MessageID field (1) of the tIENB.zero node.
			set $p(^HLB(tIENB,0),U,1)=tControlId
			// set the MessageBody Pointer field (2) of the tIENB.zero node.
			set $p(^HLB(tIENB,0),U,2)=tIENA
			// set the Direction field (4) of the tIENB.zero node, to Inbound.
			set $p(^HLB(tIENB,0),U,4)="I"
			// set the Logical Link field (5) of the tIENB.zero node,
			//  to the Sending Application.
			set $p(^HLB(tIENB,0),U,5)=tSendingApplication
			// set the Queue field (6) of the tIENB.zero node, to
			//  the ReceivingApplication.
			set $p(^HLB(tIENB,0),U,6)=tReceivingApplication
			
			// If the AcknowledgmentCode is CA for commit acknowledgment, we set
			//  the node information to purge the entry after 7 days.
			if ((tMessageCode="ACK") && (tAcknowledgmentCode="CA")) {
				// set the Final Status field (20) of the tIENB.zero node,
				//  to complete.
				set $p(^HLB(tIENB,0),U,20)="SU"
				
				// set the purge Date/Time to 7 days in the future.
				set tPurgeDate = ..GetFilemanDateTime(7)
				// set the Scheduled Purge Date field (7) of the tIENB.zero node.
				set $P(^HLB(tIENB,0),U,9)=tPurgeDate
				// set the "AD" cross reference
				set ^HLB("AD","OUT",tPurgeDate,tIENB)=""
			}
  	
			// set the Date/Time we received the message.
			set tCurrentDate = ..GetFilemanDateTime(0)
			// set the Transmission Date/Time field (16) of the tIENB.zero node
			set $p(^HLB(tIENB,0),U,16)=tCurrentDate 

			// set the tIENB.first node to the first 6 fields of the MSH segment.
			// set the tIENB.second node to the remaining fields of the MSH segment
			set ^HLB(tIENB,1)=$P(tMSHsegment,tFieldSeparator,1,6)
			set ^HLB(tIENB,2)=tFieldSeparator_$P(tMSHsegment,tFieldSeparator,7,99)
			
			// set the tIENA.zero node information.
			// Date Time Entered
			set $P(^HLA(tIENA,0),U,1)=tCurrentDate
			// Batch
			set $P(^HLA(tIENA,0),U,2)=0
			// MessageType
			set $P(^HLA(tIENA,0),U,3)=tMessageCode
			// Event
			set $P(^HLA(tIENA,0),U,4)=tTriggerEvent
			// HL7 Version
			set $P(^HLA(tIENA,0),U,5)=$P(tMSHsegment,tFieldSeparator,12)
			// HL7 Encoding Characters
			set $P(^HLA(tIENA,0),U,20)= tMessageSeparators
			
			//set B cross reference information.
			set ^HLA("B",tCurrentDate,tIENA)=""
  	  
  	  
			// The node sub-index to use in setting the HLA entries.
			set tNodeIndex=1
			for tSegmentIndex=2:1:tSegmentCount {
				// Get the segment at tSI index from the message.
				set tSegmentData=InboundMsg.GetValueAt(tSegmentIndex)
				 
     			// Place the segment information into the tIENA.1.index.zero node
				set ^HLA(tIENA,1,tNodeIndex,0)=tSegmentData
				// If we have more segments to add we place a blank in the next
				//  tIENA.1.index+1.zero node.
				if '(tSegmentIndex = tSegmentCount) {
					set ^HLA(tIENA,1,tNodeIndex+1,0)=""
				    // Increment the node sub-index by two so that the sub-index is
				    //  always odd.
				    set tNodeIndex=tNodeIndex+2
				}
			} // End of the for loop adding the message to the HLA node. 
			
			// Add the 'B', 'C' and 'SEARCH' nodes and their information.
			set ^HLB("B",tControlId,tIENB)=""
			set ^HLB("AC",$p(tMSHsegment,tFieldSeparator,4)_$p(tMSHsegment,tFieldSeparator,3)_tControlId,tIENB)=""
			// If this is a commit ACK, we don't need to process it further,
			//  so add this message to the queue only if the Acknowledgment Code
			//  is not CA.
			if '((tMessageCode="ACK") && (tAcknowledgmentCode="CA")) {
				set ^HLB("QUEUE","IN",tCurrentDate,..LLink,tMessageCode,tTriggerEvent,tIENB)=""
			}
		} // End of the If MessageCode is an ACK or MFN
    }While (0)
	
	// If the tError field equals zero, then we commit
	//  the session changes, if it is not zero  we rollback the changes.
	if '(tError) {
		TCommit
	}
    else {
	    TRollback 
	}

    // If there is information within the tText variable we send an alert
    if '(tText = "") { do ..SendAlert(tText) }
    quit $$$OK 

Trap
	// We erred out, set the error information and roll back the last transaction.
	set $ZT=""
	TRollback 
	set tSC=$$$EnsSystemError
	do ..SendAlert("Failure: The HLOGlobalOutound adapter failed: Error= "_tSC_"::")
	quit $$$OK
]]></Implementation>
</Method>

<UDLText name="T">
<Content><![CDATA[
// End the method

]]></Content>
</UDLText>

<Method name="GetNewIENA">
<Description>
Returns the next available IEN for the HLA global</Description>
<ClassMethod>1</ClassMethod>
<ReturnType>%Integer</ReturnType>
<Implementation><![CDATA[
	set tIENA=$$NEWIEN^HLOF777("IN",1)
	if '($d(^HLB(tIENA))) {quit tIENA}   // If there's no data within the HLA node at
										 //  this IEN, return the value.

	set tStartIEN = tIENA
	do {
		set tIENA = $$NEWIEN^HLOF777("IN",1)
	} while ($d(^HLA(tIENA)) && '(tStartIEN = tIENA))
	if (tStartIEN = tIENA) {quit 0}
	quit tIENA
]]></Implementation>
</Method>

<Method name="GetNewIENB">
<Description>
Returns the next available IEN for the HLB global</Description>
<ClassMethod>1</ClassMethod>
<FormalSpec>pNode:%String=""</FormalSpec>
<ReturnType>%Integer</ReturnType>
<Implementation><![CDATA[
	set tIENB=$$NEWIEN^HLOF778A("IN",1)
	if '($d(^HLB(tIENB))) {quit tIENB}   // If there's no data within the HLB node at
										 //  this IEN, return the value.

	set tStartIEN = tIENB
	do {
		set tIENB = $$NEWIEN^HLOF778A("IN",1)
	} while ($d(^HLB(tIENB)) && '(tStartIEN = tIENB))
	if (tStartIEN = tIENB) {quit 0}
	quit tIENB
]]></Implementation>
</Method>

<Method name="GetFilemanDateTime">
<Description>
Returns the date/time in FileManFormat</Description>
<ClassMethod>1</ClassMethod>
<FormalSpec>pDays:%Integer=0</FormalSpec>
<ReturnType>%String</ReturnType>
<Implementation><![CDATA[
	set tCurrentDateTime = $H
	set $P(tCurrentDateTime,",",1)=$P(tCurrentDateTime,",",1)+pDays
	set tFileManDate = ($ZDATETIME(tCurrentDateTime,8,1,9)-17000000)
	set tCurrentTime = $P(tCurrentDateTime,",",2)
	set tCurrentTimeFormatted = $ZTIME(tCurrentTime,2)
	set tFileManTime = $P(tCurrentTimeFormatted,":",1)_$P(tCurrentTimeFormatted,":",2)
	quit (tFileManDate_"."_tFileManTime)
]]></Implementation>
</Method>

<Method name="SendAlert">
<Description>
Sends an alert using the BusinessHost</Description>
<FormalSpec>pText:%String=""</FormalSpec>
<Implementation><![CDATA[	Do ..BusinessHost.SendAlert(##Class(Ens.AlertRequest).%New($LB(..BusinessHost.%ConfigName,pText)))
]]></Implementation>
</Method>
</Class>
</Export>
