Showing posts with label Segment Count. Show all posts
Showing posts with label Segment Count. Show all posts

Thursday, May 23, 2013

Intersystems Ensemble Useful Tricks

Clearing All the Message Queues in a Namespace from Command Line

NAMESPACE>do ##class(Ens.Director).CleanProduction()

This is useful when creating a new copy of an existing namespace and for other maintenance and testing purposes. Do Not use this on any Production Systems.

Get segment count in Objectscript for HL7 message
/// To be Used in rules to get the count of segments by segment name
/// pSegment is the name of the segment example "OBR"
ClassMethod GetSegmentCount(HL7 As EnsLib.HL7.Message, pSegment As %String) As %String
{
Set tIndex = ""
Set tSegCount = 0
#Dim tSegment As EnsLib.HL7.Segment
try {
Set tSegment = HL7.FindSegment(pSegment,.tIndex,.tStatus)
While (tIndex '="") {
Set tSegCount = tSegCount+1
Set tSegment = HL7.FindSegment(pSegment,.tIndex,.tStatus)
}
}
catch err {
Set tErrorText = "Error in GetSegmentCount: "_ tStatus _ ":" _ $ZError
$$$LOGERROR(tErrorText)
}
///$$$LOGERROR(tSegCount)
Quit tSegCount
}
This is useful when the number of segments needs to counted using objectscript.

Get segment count in DTL for HL7 message
<assign value='source.{PIDgrpgrp(1).ORCgrp(k1).OBXgrp("*")}' property='tMaxOBXCountInCurrentORCGroup' action='set' />

Value needs to point to the path the segment to be counted as per schema. Property is a variable to assign the count to. The variable can be used in assignments or conditions for further processing

Updating production from Command line
NAMESPACE>do ##class(Ens.Director).UpdateProduction()
This is useful when portal freezes or shows lck err when update button is used from the management portal.

Getting Globals Size from the command line
NAMESPACE>do ^%GSIZE
This routine provides detailed global size information. Depending on the size of the Cache.dat it can run a few hours to days.

Getting the size of cache and the free count
NAMESPACE>do ^%FREECNT
This routine provides the cache size and free space available very very quickly

This will be a work in progress and I will keep adding content to this blog