Class UMMS.UMMC.HL7.ALL.RouterRoutines Extends Ens.Rule.FunctionSet
{
ClassMethod SetDocTypeId(pMessageId As %String, pDocType As %String) As %String
{
set $ZTRAP="SetDocTypeIdError"
set oref=##class(EnsLib.HL7.Message).%OpenId(pMessageId)
if '$IsObject(oref) {
&js<document.all.display.innerHTML='Unable to open HL7 message';>
quit
}
s oldDT = oref.DocType
s oref.DocType = pDocType
// the next call doesn't seem to be necessary unless we are running from the terminal
// (at least as long as the production isn't bounced!)
do oref.%Save()
// only see in router's log if trace is enabled
$$$TRACE("ROUTER TESTING:: Was able to set old oref.DocType ["_oldDT_"] to new ["_oref.DocType_"] from passed in ["_pDocType_"] for msgID ["_pMessageId_"] ...\n")
Quit 1
SetDocTypeIdError
set $ZTRAP=""
If $ZE $$$LOGERROR("$ZE: "_$ZE) //test unnecessary but ...
$$$TRACE( "error setting ID doctype ["_pDocType_"] for ID ["_pMessageId_"] ... \n\n" )
quit ""
}
}
Nicole,
Since dates are treating as text, you don't have to necessarily ask the length, or size. Normally, in HL7, you can just test for presence:
When
(HL7.{MSH:9.2}!="A03")&&(HL7.{PV1:45}!="")
Send -> {Business Operation}
This works to send any message not a discharge and containing a date (with or without transformation).
Examples of calling a function from csession, and setting DocType ad hoc:
ENSEMBLE>do ##class(UMMS.UMMC.HL7.ALL.RouterRoutines).SetDocTypeId( "40382754","2.3:ORM_O01")
/// note: quotes around the msgId don't seem to be necessary. Cache casts num to string?
/// Also, the shorter version of above is:
/// ENSEMBLE>set oref=##class(EnsLib.HL7.Message).%OpenId(40382754)
/// ENSEMBLE>s oref.DocType = "2.3:ORM_O01"
/// ENSEMBLE>w oref.DocType
/// 2.3:ORM_O01
/// ENSEMBLE>do oref.%Save()Examples of calling ad hoc:
...where msgId is the first number listed in the Message Viewer Contents panel.