No sweat. Here is a vbscript that I wrote to handle little conversion tasks like this from time to time. It loops through the results of a query creating one hl7 ORU message per record and saves the results to a folder on your drive. From there it's just a matter of highjacking one of your HL7 lab interfaces to copy the files over then watch them import observation data using linklogic. Ironically, it looks like I last used this script to import using our eformslab interface that came with our patient portal. I changed the query to yours.
1. Add a new line to cross-reference the METHCONTACT on your interface's .xref file
I,METHCONTACT,MLI-95886
2. Copy & Paste the script starting below '''''QUERY RESULTS TO HL7'''' into notepad. You can modify the doc type/summary by changing these variables:
DocumentType="PL" 'Preload or can be whatever existing doctype (abbreviation) you choose'
DocumentSummary="METHCONTACT Import"
3. Fill in your database connection information:
dbGE.open "Provider=sqloledb;Data Source=SERVERNAME;Initial Catalog=DATABASENAME;User ID=xxxxx;password=xxxxx;"
4. You will need to update the hl7 message headers to match your interface:
msh="MSH|^~\&|eFormsLab|Tahoe Fracture and Orthopaedic Clinic|LinkLogic|CPS|" & msgDate & "||ORU|" & msgDate & "|P|2.3|||||||"
5. Create the folder below or change the folder path to an existing folder. It will not create the folder for you. This is where the messages will be saved.
Set filetxt = filesys.CreateTextFile("c:\extract\" & PatientID & ".hr", True)
6. Save the file as "extract.vbs", make sure you save it as type: "All Files", instead of .txt.
7. Double click the file to run the script. If successful it should give you a total exported recordcount. Could take a while if you have quite a few records.
8. Open the folder the messages were saved to and copy and paste the files into the folder that your linklogic interface is monitoring. You might want to start by copying a couple test messages to make sure it's working. Might want to double check the documents are coming in as signed.
9. It should create a new document based on the document parameters provided above and update your METHCONTACT obsterms accordingly.
Sorry for the lack of comments and error handling in my code. Good luck...
Allen
'''''''''''''''''''''QUERY RESULTS TO HL7''''''''''''''''''''''''''''''''''''
function AddZero(strVal)
if strVal < 10 then
AddZero="0" & strVal
else
AddZero=strVal
end if
end function
function fmtHL7Date(theDate,lType)
dim yy
dim mm
dim dd
dim hl7Date
dim hl7Time
dim hh
dim nn
dim ss
yy=Year(theDate)
mm=AddZero(Month(theDate))
dd=AddZero(Day(theDate))
hl7Date=yy&mm&dd
hh=AddZero(Hour(theDate))
nn=AddZero(Minute(theDate))
ss=AddZero(Second(theDate))
hl7Time=hh&nn&ss
if lType=1 then
fmtHL7Date=hl7Date
else
fmtHL7Date=hl7Date & hl7Time
end if
end function
dim filesys
dim filetxt
dim dbGE
dim rs
dim msh
dim pid
dim pv1
dim obr
dim nte
dim obx
dim hl7
dim sql
dim DocumentType
dim DocumentSummary
dim TotalRecords
DocumentType="PL" 'Preload'
DocumentSummary="METHCONTACT Import"
Set dbGE=CreateObject("ADODB.Connection")
Set rs= CreateObject("ADODB.Recordset")
Set filesys = CreateObject("Scripting.FileSystemObject")
dbGE.open "Provider=sqloledb;Data Source=SERVERNAME;Initial Catalog=DATABASENAME;User ID=xxxxx;password=xxxxx;"
sql="select PatientProfileId,First,Middle,last,Address1,Address2,City,State,Zip,SSN,Birthdate,Sex from dbo.PatientProfile where ProfileNotes like '%!!EMAIL!!%'"
rs.open sql,dbGE,3,1
TotalRecords=rs.recordcount
for i= 1 to rs.recordcount
PatientID=rs("PatientProfileID")
PatientLast=rs("Last")
PatientFirst=rs("First")
PatientMiddle=rs("Middle")
PatientDOB=fmtHL7Date(rs("BirthDate"),1)
PatientSex=rs("Sex")
PatientStreet=rs("Address1")
PatientCity=rs("City")
PatientState=rs("State")
PatientZip=rs("Zip")
msgdate=fmtHL7Date(Now(),0)
msh="MSH|^~\&|eFormsLab|Tahoe Fracture and Orthopaedic Clinic|LinkLogic|CPS|" & msgDate & "||ORU|" & msgDate & "|P|2.3|||||||"
pid="PID|0001||" & PatientID & "||" & PatientLast & "^" & PatientFirst & "^" & PatientMiddle & "^^||" & PatientDOB & "|" & PatientSex & "|||" & PatientStreet & "^^" & PatientCity & "^" & PatientState & "^" & Patientzip & "^|||||||||||||||||||"
pv1="PV1|0001|||||||||||||||||||||||||||||||||||||||||||||||||||"
obr="OBR|0001|||^" & DocumentSummary & "|||" & msgdate & "|||||||" & msgdate & "||||" & DocumentType & "||||" & msgdate & "|||F||||||||||||||||||"
obx="OBX|0001|ST|METHCONTACT^METHCONTACT||E-mail||||||F|||" & msgdate & "|||" & vbcrlf
hl7=msh & vbcrlf & pid & vbcrlf & pv1 & vbcrlf & obr & vbcrlf & obx
Set filetxt = filesys.CreateTextFile("c:\extract\" & PatientID & ".hr", True)
filetxt.Write(hl7)
filetxt.Close
rs.movenext
next
set filesys=nothing
Set rs=nothing
dbGE.close
msgbox("Exported " & TotalRecords & " Records")