Forum Replies Created
-
AuthorReplies
-
October 14, 2024 at 2:49 pm in reply to: SQL Table update Query and formatting from a string to a date #121637
Hi,
Can someone please tell me what the issue is with my query below?
Error string “BADDATA caught exception trying to processMessageFromCloverleaf: Failed to write message to database: Incorrect syntax near ‘<‘.”. Returning bad send to engine.
UPDATE IMS_TCHEADER
SET
IMS_TCHEADER. FILLER=NULL,
IMS_TCHEADER.FILLER1=’Y’, IMS_TCHEADER.RowUpdateDateTime=GETDATE(), IMS_TCHEADER.TCHEADERACTINACTIND=<‘IMS_TCHEADER.TCHEADERACTINACTIND’>, IMS_TCHEADER.TCHEADERAGRMNTDATE=<‘IMS_TCHEADER.TCHEADERAGRMNTDATE’>, IMS_TCHEADER.TCHEADERCONSIGNAVAIL=NULL, IMS_TCHEADER.TCHEADERCTRCTEFFDATE=<‘IMS_TCHEADER.TCHEADERCTRCTEFFDATE’>, IMS_TCHEADER.TCHEADERCTRCTEXPDATE=<‘IMS_TCHEADER.TCHEADERCTRCTEXPDATE’>, IMS_TCHEADER.TCHEADERCTRCTNBR=<‘IMS_TCHEADER.TCHEADERCTRCTNBR’>, IMS_TCHEADER.TCHEADERCTRCTREVDATE=<‘IMS_TCHEADER.TCHEADERCTRCTREVDATE’>, IMS_TCHEADER.TCHEADERCTRCTSTATUS=<‘IMS_TCHEADER.TCHEADERCTRCTSTATUS’>, IMS_TCHEADER.TCHEADERCTRCTTYPE=<‘IMS_TCHEADER.TCHEADERCTRCTTYPE’>, IMS_TCHEADER.TCHEADERCTRTAVAILABLE=<‘IMS_TCHEADER.TCHEADERCTRTAVAILABLE’>, IMS_TCHEADER.TCHEADERCTRTCLASS=<‘IMS_TCHEADER.TCHEADERCTRTCLASS’>, IMS_TCHEADER.TCHEADERDISCAPPLIEDTO=NULL, IMS_TCHEADER.TCHEADERDISTCOORDNAME=NULL, IMS_TCHEADER.TCHEADERDISTCOORDPHONE=NULL, IMS_TCHEADER.TCHEADEREDITERMSA=NULL, IMS_TCHEADER.TCHEADEREDITERMSB=NULL, IMS_TCHEADER.TCHEADEREDITERMSCODE=’5′, IMS_TCHEADER.TCHEADEREDITERMSDAYS=’0′, IMS_TCHEADER.TCHEADEREDITERMSDISC=’0′, IMS_TCHEADER.TCHEADERFOB=<‘IMS_TCHEADER.TCHEADERFOB’>, IMS_TCHEADER.TCHEADERMARKUPFLAG=’N’, IMS_TCHEADER.TCHEADERMFRCOORDNAME=NULL, IMS_TCHEADER.TCHEADERMFRCOORDPHONE=NULL, IMS_TCHEADER.TCHEADERMINIMUMORDERAMT=’0′, IMS_TCHEADER.TCHEADERMINIMUMORDERQTY=’0′, IMS_TCHEADER.TCHEADERNATVENDORNBR=<‘IMS_TCHEADER.TCHEADERNATVENDORNBR’>, IMS_TCHEADER.TCHEADERNBRRENEWALS=’0′, IMS_TCHEADER.TCHEADERORDERVENDORNBR=NULL, IMS_TCHEADER.TCHEADERPRICINGFIRMTHRU=<‘IMS_TCHEADER.TCHEADERPRICINGFIRMTHRU’>, IMS_TCHEADER.TCHEADERPRODUCTGROUPING=<‘IMS_TCHEADER.TCHEADERPRODUCTGROUPING’>, IMS_TCHEADER.TCHEADERPUOM=NULL, IMS_TCHEADER.TCHEADERREBATECODE=’N’, IMS_TCHEADER.TCHEADERREMARKS1=NULL, IMS_TCHEADER.TCHEADERREMARKS2=NULL, IMS_TCHEADER.TCHEADERREMARKS3=NULL, IMS_TCHEADER.TCHEADERTERMS=<‘IMS_TCHEADER.TCHEADERTERMS’>, IMS_TCHEADER.TCHEADERTERMSA=NULL, IMS_TCHEADER.TCHEADERTERMSB=’Not Applicable’, IMS_TCHEADER.TCHEADERTERMSCODE=’5′, IMS_TCHEADER.TCHEADERTERMSDAYS=’0′, IMS_TCHEADER.TCHEADERTERMSDISC=’0′, IMS_TCHEADER.TCHEADERTERMSFOB=’4′, IMS_TCHEADER.TCHEADERVALUEADDS=NULL WHERE IMS_TCHEADER.TCHEADERNATVENDORNBR=<‘IMS_TCHEADER^TCHEADERNATVENDORNBR’> and IMS_TCHEADER.TCHEADERCTRCTNBR=<‘IMS_TCHEADER^TCHEADERCTRCTNBR’>
Thanks Jim.
Now I need help with writing a TRIX_id tcl please using the commands keylget and keylset and USERDATA
I want to extract 3 types files where the msgDriverControl /Protocol Driver may have either
- IMS_Daily or
- IMS_CVENDOR or
- IMS_TCHEADER
- All the others can be killed
I have attached Metadata and Protocol Driver screenshots.
********************************
Something like this
proc IMSFiles { args } {
global HciConnName
keylget args MODE mode
set ctx “” ; keylget args CONTEXT ctx
set module “IMSFiles/$HciConnName/$ctx”
set uargs {} ; keylget args ARGS uargs
set debug 0
catch {keylget uargs DEBUG debug}
set dispList {}switch -exact — $mode {
start {}run {
set udata [msgmetaget $mh USERDATA]
keylget args MSGID mh #Get Message
echo “message is: |$msg|”
set TRXID “”
keylset udata IMS_Filename $msgDriverControlId
msgmetaset $mh USERDATA $udataAttachments:
You must be logged in to view attached files.September 17, 2024 at 10:38 am in reply to: Unable to select all the rows when creating a Database Schema. #121614It didn’t make any difference.
September 17, 2024 at 6:11 am in reply to: Unable to select all the rows when creating a Database Schema. #121610Hi John,
Some is odd again!
I am unable to select all the column names in one of the table but can on the other?
Please refer to my screenshots to see the difference.Attachments:
You must be logged in to view attached files.September 10, 2024 at 3:59 am in reply to: Unable to select all the rows when creating a Database Schema. #121596This has done the trick.
Thank you.
September 6, 2024 at 10:51 am in reply to: Unable to select all the rows when creating a Database Schema. #121592Thanks John.
Thank you David.
Also, 1 silly qn please,
Qn #3:
Why is the “errormsg” set at the top does not get displayed in an email?
I tried changing the variable to an “error” but still the same?
set errormsg “This is the message ID: $MSH_10 \n\n This is the reason why:\n\n $errormsg \n\n The Order Id is : (OBR.2) $OBR_2”
*****************************************
The email only shows the details below:
“This is the message ID: ORDERS-OUT.12.2431267
This is the reason why:
The Order Id is : (OBR.2) CARD20240730-0002COCLB”
In addition to the above, I would also expect the line below to be displayed in my email:
“This message has no MRN identifier included.”
Hi David,
Just to clarify,
(1) This line (.1):
set found_mrn [hl7::get_field hl7 PID.3(5=MR).1]
Does “.1” mean PID3.5.1 field value?
(2) I know I am not using the “for” look in the code above anymore but,
for { set i 1 } { $i <= [hl7::count hl7 PID.3] } { incr i } {
Does the above mean that loop through the repitions of PID-3 field and incremented by 1 after each loop i.e. after every “~” in PID-3?
Hi David,This has worked without a for loop.Thank you, nice and simple solution.proc tpsMissingMRN_1 { args } {
global HciConnName
keylget args MODE mode
set ctx “” ; keylget args CONTEXT ctx
set module “tpsMissingMRN/$HciConnName/$ctx”
set uargs {} ; keylget args ARGS uargs
set debug 0
catch {keylget uargs DEBUG debug}
set dispList {}switch -exact — $mode {
start {}run {
keylget args MSGID mh
package require hl7
set hl7 [hl7::parse_msg [msgget $mh]]
set MSH_10 [hl7::get_field hl7 MSH.10]
set PID_3 [hl7::get_field hl7 PID.3]
set PID_3_1 [hl7::get_field hl7 PID.3.1]
set PID_3_5 [hl7::get_field hl7 PID.3.5]
set OBR_2 [hl7::get_field hl7 OBR.2]
echo “MSH_10: $MSH_10”
echo “OBR_2: $OBR_2”set found_mrn [hl7::get_field hl7 PID.3(5=MR).1]
if { $found_mrn ne “” } {
lappend dispList “CONTINUE $mh”
echo found mrn $found_mrn} else {
# Send an error message
set errormsg “This message has no MRN identifier included.”
echo “Killing message with Message Control ID: |$MSH_10| because of $errormsg”
lappend dispList “KILL $mh”
}#SOURCECONN is the name of the thread that initially receives the message (CARD_Orders_from_Meditech)
set sourceconn [msgmetaget $mh SOURCECONN]
set errormsg “”if {$sourceconn eq “”} {
set sourceconn TestTool
}#Create the e-mail
###echo “This is sourceconn: |$sourceconn|”
set mailto [tbllookup Missing_MRN_Email $sourceconn]
echo “This is mailto: |$mailto|”
set mailfrom [tbllookup Missing_MRN_Email “MailFrom”]
set mailhost [tbllookup Missing_MRN_Email “MailHost”]
set PORT [tbllookup Missing_MRN_Email “MailPort”]
set mailsubjectprefix [tbllookup Missing_MRN_Email “MailSubjectPrefix”]
set subject “$mailsubjectprefix Meditech sent an HL7 Order Message without the MRM number to Cloverleaf”
set errormsg “This is the message ID: $MSH_10 \n\n This is the reason why:\n\n$errormsg \n\n The Order Id is : (OBR.2) $OBR_2”
#echo “This is errormsg: |$errormsg|”
set emailbody $errormsgSendEmailAsAlert $mailto “” $emailbody $subject $mailfrom “” “” $mailhost $PORT “0” “0”
###echo “email should have been send now”} else {
lappend dispList “CONTINUE $mh”
}time {}
shutdown {}
default {
error “Unknown mode ‘$mode’ in $module”
}
}return $dispList
}Hi David,
I replaced
for { set i 1 } { $i <= [hl7::count hl7 PID.3] } { incr i } {
with your suggested line,
set mrn [hl7::get_field hl7 PID.3(5=MR).1]
but it errored?
Thanks David,
I will try it.
Finally works now!
Many thanks to everyone.If anybody has any TCL with Cloverleaf training guide or good tcl example re-usable scripts, please let me know.
######################################################################
# Name: tpsMissingMRN
# Purpose: This will pick up relevant details from the ADT and ORM message from Meditech and send an e-mail#############################################################
proc tpsMissingMRN { args } {
global HciConnName
keylget args MODE mode
set ctx “” ; keylget args CONTEXT ctx
set module “tpsMissingMRN/$HciConnName/$ctx”
set uargs {} ; keylget args ARGS uargs
set debug 0
catch {keylget uargs DEBUG debug}
set dispList {}switch -exact — $mode {
start {}run {
keylget args MSGID mh
package require hl7
set hl7 [hl7::parse_msg [msgget $mh]]
set MSH_10 [hl7::get_field hl7 MSH.10]
set PID_3 [hl7::get_field hl7 PID.3]
set PID_3_1 [hl7::get_field hl7 PID.3.1]
set PID_3_5 [hl7::get_field hl7 PID.3.5]
echo “MSH_10: $MSH_10”
echo “PID_3: $PID_3”set pid_counter 0
#SOURCECONN is the name of the thread that initially receives the message (CARD_Orders_from_Meditech)
set sourceconn [msgmetaget $mh SOURCECONN]
set errormsg “”if {$sourceconn eq “”} {
set sourceconn TestTool
}for { set i 1 } { $i <= [hl7::count hl7 PID.3] } { incr i } {
echo Hi entering IF statement
if { [hl7::get_field hl7 PID.3($i).5] eq “MR”} {
echo pid_counter before $pid_counter
incr pid_counter
echo pid_counter after $pid_counter}
}
if {$pid_counter eq 0} {
# Send an error message
set errormsg “This message has no MRN identifier included.”
echo “Killing message with Message Control ID: |$MSH_10| because of $errormsg”
lappend dispList “KILL $mh”#Create the e-mail
###echo “This is sourceconn: |$sourceconn|”
set mailto [tbllookup Missing_MRN_Email $sourceconn]
echo “This is mailto: |$mailto|”
set mailfrom [tbllookup Missing_MRN_Email “MailFrom”]
set mailhost [tbllookup Missing_MRN_Email “MailHost”]
set PORT [tbllookup Missing_MRN_Email “MailPort”]
set mailsubjectprefix [tbllookup Missing_MRN_Email “MailSubjectPrefix”]
#set subject “$mailsubjectprefix Cloverleaf – Patient X Number: $PID_3_1 – THH message from $MSH_5 i.e. thread $sourceconn with message ID $MSH_10 needs manual intervention!”
set subject “$mailsubjectprefix Meditech sent an HL7 Order Message without the MRM number to Cloverleaf”
#set errormsg “This is the message ID: $MSH_10 \nThis is the reason why:\n\n$errormsg \n Patient X Number: $PID_3_1 \n Minor Patient ID: $MRG_1_1 \n The Major UHB patient ID is: $PID_4_1 \n The minor UHB Patient ID is: $mrgid\n\n Please check that the UHB ID matches the correct HCA Patient ID.”
set errormsg “This is the message ID: $MSH_10 \n\n This is the reason why:\n\n$errormsg \n Patient X Number: (PID.3) $PID_3”
#echo “This is errormsg: |$errormsg|”
set emailbody $errormsgSendEmailAsAlert $mailto “” $emailbody $subject $mailfrom “” “” $mailhost $PORT “0” “0”
###echo “email should have been send now”} else {
lappend dispList “CONTINUE $mh”
}}
time {}
shutdown {}
default {
error “Unknown mode ‘$mode’ in $module”
}
}return $dispList
}Hi Tim ,
Please IGNORE the above,
I have added a new error below:
Error:
MSH_10: ORDERS-OUT.12.2431267PID_3: X1234785^^^^PI~123456^^^^MR[0:TEST] Tcl error:msgId= message0proc= ‘tpsMissingMRN’args= ”result= ‘can’t read “1”: no such variable’errorInfo: ‘can’t read “1”: no such variablewhile executing“hl7::get_field hl7 PID.3.($1).5”(procedure “tpsMissingMRN” line 30)invoked from within“tpsMissingMRN {MSGID message0} {CONTEXT sms_ib_data} {ARGS {}} {MODE run} {VERSION 3.0}”‘**********************************
SCRIPT:
######################################################################
# Name: tpsMissingMRN
# Purpose: This will pick up relevant details from the ADT and ORM message from Meditech and send an e-mail
# to people decodefined for Missing PID-3 in table Missing_MRN_Email.tbl
#############################################################proc tpsMissingMRN { args } {
global HciConnName
keylget args MODE mode
set ctx “” ; keylget args CONTEXT ctx
set module “tpsMissingMRN/$HciConnName/$ctx”
set uargs {} ; keylget args ARGS uargs
set debug 0
catch {keylget uargs DEBUG debug}
set dispList {}switch -exact — $mode {
start {}run {
keylget args MSGID mh
package require hl7
set hl7 [hl7::parse_msg [msgget $mh]]
set MSH_10 [hl7::get_field hl7 MSH.10]
set PID_3 [hl7::get_field hl7 PID.3]
set PID_3_1 [hl7::get_field hl7 PID.3.1]
set PID_3_5 [hl7::get_field hl7 PID.3.5]
echo “MSH_10: $MSH_10”
echo “PID_3: $PID_3”set pid_counter 0
set found_mrn “”
for { set i 1 } { $i < [hl7::count hl7 PID.3] } { incr i } {
incr pid_counterif { [hl7::get_field hl7 PID.3.($1).5] eq “MR”} {
set found_mrn [hl7::get_field hl7 PID.3($i).1]
lappend dispList “CONTINUE $mh”
echo found mrn $found_mrn} else {
if {[$found_mrn eq “”]}
# Send an error message
set errormsg “This message has no MRN identifier included.”
echo “Killing message with Message Control ID: |$MSH_10| because of $errormsg”
lappend dispList “KILL $mh”
}#SOURCECONN is the name of the thread that initially receives the message (CARD_Orders_from_Meditech)
set sourceconn [msgmetaget $mh SOURCECONN]
set errormsg “”if {$sourceconn eq “”} {
set sourceconn TestTool
}#Create the e-mail
###echo “This is sourceconn: |$sourceconn|”
set mailto [tbllookup Missing_MRN_Email $sourceconn]
#echo “This is mailto: |$mailto|”
set mailfrom [tbllookup Missing_MRN_Email “MailFrom”]
set mailhost [tbllookup Missing_MRN_Email “MailHost”]
set PORT [tbllookup Missing_MRN_Email “MailPort”]
set mailsubjectprefix [tbllookup Missing_MRN_Email “MailSubjectPrefix”]
#set subject “$mailsubjectprefix Cloverleaf – Patient X Number: $PID_3_1 – THH message from $MSH_5 i.e. thread $sourceconn with message ID $MSH_10 needs manual intervention!”
set subject “$mailsubjectprefix Meditech sent an HL7 Order Message without the MRM number to Cloverleaf”
#set errormsg “This is the message ID: $MSH_10 \nThis is the reason why:\n\n$errormsg \n Patient X Number: $PID_3_1 \n Minor Patient ID: $MRG_1_1 \n The Major UHB patient ID is: $PID_4_1 \n The minor UHB Patient ID is: $mrgid\n\n Please check that the UHB ID matches the correct HCA Patient ID.”
set errormsg “This is the message ID: $MSH_10 \n\n This is the reason why:\n\n$errormsg \n Patient X Number: (PID.3) $PID_3”
#echo “This is errormsg: |$errormsg|”
set emailbody $errormsgSendEmailAsAlert $mailto “” $emailbody $subject $mailfrom “” “” $mailhost $PORT “0” “0”
###echo “email should have been send now”}}
time {}
shutdown {}
default {
error “Unknown mode ‘$mode’ in $module”
}return $dispList
}
}HI Tim,
Thank you, edited but still erroring?
MSH_3:MSH_10: ORDERS-OUT.12.2431267PID_3: X1234785^^^^PI~123456^^^^MR[0:TEST] Tcl error:msgId= message0proc= ‘tpsMissingMRN’args= ”result= ‘expected integer but got “=0″‘errorInfo: ‘expected integer but got “=0”while executing“incr pid_counter “(procedure “tpsMissingMRN” line 30)invoked from within“tpsMissingMRN {MSGID message0} {CONTEXT sms_ib_data} {ARGS {}} {MODE run} {VERSION 3.0}”‘*****************************************************************
Script:
######################################################################
# Name: tpsMissingMRN
# Purpose: This will pick up relevant details from the ADT and ORM message from Meditech and send an e-mail
###########################################################proc tpsMissingMRN { args } {
global HciConnName
keylget args MODE mode
set ctx “” ; keylget args CONTEXT ctx
set module “tpsMissingMRN/$HciConnName/$ctx”
set uargs {} ; keylget args ARGS uargs
set debug 0
catch {keylget uargs DEBUG debug}
set dispList {}switch -exact — $mode {
start {}run {
keylget args MSGID mh
package require hl7
set hl7 [hl7::parse_msg [msgget $mh]]
set MSH_3 [hl7::get_field hl7 MSH.3]
set MSH_10 [hl7::get_field hl7 MSH.10]
set PID_3 [hl7::get_field hl7 PID.3]
set PID_3_1 [hl7::get_field hl7 PID.3.1]
set PID_3_5 [hl7::get_field hl7 PID.3.5]
echo “MSH_3: $MSH_3”
echo “MSH_10: $MSH_10”
echo “PID_3: $PID_3”set pid_counter =0
set found_mrn “”
for { set i 1 } { $i < [hl7::count hl7 PID.3] } { incr i } {
incr pid_counterif { [hl7::get_field hl7 PID.3.($1).5] eq “MR”} {
set found_mrn [hl7::get_field hl7 PID.3($i).1]
lappend dispList “CONTINUE $mh”} else {
if {[$found_mrn eq “”]}
# Send an error message
set errormsg “This message has no MRN identifier included.”
echo “Killing message with Message Control ID: |$MSH_10| because of $errormsg”
lappend dispList “KILL $mh”
}#SOURCECONN is the name of the thread that initially receives the message (CARD_Orders_from_Meditech)
set sourceconn [msgmetaget $mh SOURCECONN]
set errormsg “”if {$sourceconn eq “”} {
set sourceconn TestTool
}#Create the e-mail
###echo “This is sourceconn: |$sourceconn|”
set mailto [tbllookup Missing_MRN_Email $sourceconn]
#echo “This is mailto: |$mailto|”
set mailfrom [tbllookup Missing_MRN_Email “MailFrom”]
set mailhost [tbllookup Missing_MRN_Email “MailHost”]
set PORT [tbllookup Missing_MRN_Email “MailPort”]
set mailsubjectprefix [tbllookup Missing_MRN_Email “MailSubjectPrefix”]
#set subject “$mailsubjectprefix Cloverleaf – Patient X Number: $PID_3_1 – THH message from $MSH_5 i.e. thread $sourceconn with message ID $MSH_10 needs manual intervention!”
set subject “$mailsubjectprefix Meditech sent an HL7 Order Message without the MRM number to Cloverleaf”
#set errormsg “This is the message ID: $MSH_10 \nThis is the reason why:\n\n$errormsg \n Patient X Number: $PID_3_1 \n Minor Patient ID: $MRG_1_1 \n The Major UHB patient ID is: $PID_4_1 \n The minor UHB Patient ID is: $mrgid\n\n Please check that the UHB ID matches the correct HCA Patient ID.”
set errormsg “This is the message ID: $MSH_10 \n\n This is the reason why:\n\n$errormsg \n Patient X Number: (PID.3) $PID_3”
#echo “This is errormsg: |$errormsg|”
set emailbody $errormsgSendEmailAsAlert $mailto “” $emailbody $subject $mailfrom “” “” $mailhost $PORT “0” “0”
###echo “email should have been send now”}}
time {}
shutdown {}
default {
error “Unknown mode ‘$mode’ in $module”
}return $dispList
}
} -
AuthorReplies