Outbound Document Interface

From Galen Healthcare Solutions - Allscripts TouchWorks EHR Wiki
Jump to: navigation, search

Enable

To turn on the Outbound Document Interface, you must update a table in the database called Preference. The preference is: DocumentWriteOutboundEvent and must be set to Y in the Works database:

UPDATE Preference SET Setting = 'Y' 
WHERE Name = 'DocumentWriteOutboundEvent'

Events

All actions on documents/notes create an event, with the exception of viewing, printing and faxing. These events are posted to the Event_Table for ConnectR to process. The Outbound Document Interface must be setup to receive and process the events appropriately. You would limit the events in ConnectR, based on Status, Source (the EHR, or Interface) and other appropriate criteria.

Inbound documents

Inbound documents do process in as Events that are sent outbound.

DOC Message Construction

DOC Msg Construction.jpg

Document Text

The document text is not available as output of the "Extract" stored procedures as illustrated above. As such, a ConnectR script is utilized to extract the document text by the DocID (SupersetData-[7] - ItemID):

function GetDocumentTextLIVE(DocID)

Dim oCon
Dim oRS
Dim vcommand
Dim datasource
Dim user
Dim pass

'Pass in Document IDto be searched for.  This script will select against that document table and return the text of the document to be sent in the interface.

datasource = "Works"
user = "connectr"
pass = "connectr"

'Establish the Connection

Set oCon = CreateObject("ADODB.Connection")           'This Creates the database object
oCon.Open "Data Source=" & datasource, user, pass    'This opens the object --  data source, username, password

'Do the lookup on the dictionary

'vcommand = "select * from document where documentid="  & DocID

vcommand = "select physicalmanifestation_de.Entrycode as PhysicalManifestation, document.editablechunk as EditableChunk, document.uneditablechunk as UneditableChunk from document inner join physicalmanifestation_de on physicalmanifestation_de.id =  document.physicalmanifestationde  where documentid= "  & DocID


Set oRS = CreateObject("ADODB.Recordset")
oRS.Open vcommand, oCon, 3, 1, -1

Dim physicalManifestation
Dim editableChunk
Dim uneditableChunk
Dim oRTF 
Dim rtfText


physicalManifestation = ORS("PhysicalManifestation")
editableChunk = ORS("editableChunk")
uneditableChunk = ORS("UneditableChunk")


'Set objReg=CreateObject("vbscript.regexp")
'objReg.Pattern="SectionStart"
'editableChunk = objReg.Replace(editableChunk,"")


'Set objReg2=CreateObject("vbscript.regexp")
'objReg2.Pattern = "SectionStart"
'uneditableChunk = objReg2.Replace(uneditableChunk,"")



if physicalManifestation = "RTF       " Then
    rtfText = editableChunk + uneditableChunk
elseif physicalManifestation = "HTML      " or physicalManifestation =  "NOTEFORM  " Then
    rtfText = editableChunk
else
    rtfText = "Manifestation type not recognized"
end if


Set oRTF = CreateObject("AHSRTFUtility.RTFObject") 

oRTF.Value = rtfText

GetDocumentTextLIVE = oRTF.Text
                oRS.Close
                oCon.Close 
                Set oRS = Nothing
                Set oCon = Nothing         
               
                Set oRTF = Nothing
end function