Hi Stephen

I developed an Alert management system Ensemble based that you might find of interest.

It connects to the end user systems via Email ( it was intended to serve hospitals & they don't like web services as its  not protected enough, yet you can use any connection ) , the system reads the alerts process them & send them further for processing, I'll try to send you some screen shots.

Simcha

ps my email is shiluvg@gmail.com if you are interested

pps I tried to upload the screen shots with no success if you'll send me your email I'll be able to send you the files

Hi Chris

You made a wonderful work, I'm enjoying studying it, thanks.

I have a problem I reach the level of inserting 'ngMaterial' into my JS code.

When doing it my page looks like it can't load the js (just the html & css appears) , even when I deleted -  module('WidgetsDirect',['']) , it still doesn't work.

I had to delete the csp & js , when writing it again worked again until I inserted the ngMaterial.

As I'm a novice to all this stuff (JS Angular etc. ) I would appreciate your help, thanks.

 

I can't attach the snap shots in this frame so could see, if it's possible can you send me your email so I'll be able to attach those snap shots.

Thanks Simcha

This is the object class I try to save (ps is there any way to upload a file here?)

The area in red is where I do my save.

There are no  callbacks on save methods .

This is the version I use : Cache for Windows (x86-64) 2015.2.2 (Build 805U) Thu Dec 10 2015 16:31:16 EST

This is the error I get :

ELAD>zw ^sghp1
^sghp1="0 "_$c(134,1,4,4)_"­"_$c(22)_"+"_$c(1)_"Elad.AlertManagment.Data.Tables.AlertSort%"_$c(1)_"^Elad.AlertManagme1E8.AlertSortD(1)$"_$c(1)_"""^Elad.AlertManagme1E8.AlertSortD"""_$c(2,1,2,1,2,1,2,1,2,1,2,1)_"**SHEBA**SHE**SHE**DatexGetFiles Gynecology : Production - sheba - Production:Elad.Productions.Sheba!!!InactivityTimeoutAlert: Inactivity timeout of '3600' seconds exceeded for host 'DatexGetFiles Gynecology'!!!!!!2016-11-08 07:21:21.794!!!"
^sghp1(1)="0 "_$c(134,1,4,4)_"­"_$c(22)_"+"_$c(1)_"Elad.AlertManagment.Data.Tables.AlertSort%"_$c(1)_"^Elad.AlertManagme1E8.AlertSortD(1)$"_$c(1)_"""^Elad.AlertManagme1E8.AlertSortD"""_$c(2,1,2,1,2,1,2,1,2,1,2,1)_"**SAVION**VET**VET**Ens.Alert :  - savion - Production:Productions.BeitDagan!!!InactivityTimeoutAlert: Inactivity timeout of '120' seconds exceeded for host 'Ens.Alert'!!!!!!2016-09-06 13:22:56.082!!!695157"
 
ELAD>w $system.OBJ.DisplayError(^sghp1)
 
ERROR #5034: Invalid status code structure ("0 "_$c(134,1,4,4)_"­"_$c(22)_"+"_$c(1)_"Elad.AlertManagment.Data.Tables.AlertSort%"_$c(1)_"^Elad.AlertManagme1E8.AlertSortD(1)$"_$c(1)_"""^Elad.AlertManagme1E8.AlertSortD"""_$c(2,1,2,1,2,1,2,1,2,1,2,1)_"**SHEBA**SHE**SHE**DatexGetFiles Gynecology : Production - sheba - Production:Elad.Productions.Sheba!!!InactivityTimeoutAlert: Inactivity timeout of '3600' seconds exceeded for host 'DatexGetFiles Gynecology'!!!!!!2016-11-08 07:21:21.794!!!")1
ELAD>

 

 

 

/// Contains the persistent managed alerts
Class Elad.AlertManagment.Data.ManagedAlert Extends (%Persistent, %XML.Adaptor, %ZEN.DataModel.Adaptor)
{

/// New Id managed by the monitoring system
/// AAANNNNNN - AAA - OrganizationInitials, NNNNNN ( not definite number) is either
/// SessionId from Ensemble in a recognized hospital or SUR_$i(^Elad.AlertMan669B.ManagedAlertD)
Property ManagedAlertID As %String [ Required ];

Property IsOpen As %Integer(MAXVAL = 1, MINVAL = 0) [ InitialExpression = 1, Required ];

/// The Managed Alert SessionId ID As send from the intiating System
Property OriginalAlertSessionId As %String;

/// when the same error is reported again
Property NumberOfReportsOfTheSameError As %String;

Property AlertType As Elad.AlertManagment.Data.Tables.AlertType;

/// Orinited by : Inactivity, System, Other
Property AlertSort As Elad.AlertManagment.Data.Tables.AlertSort;

Property ErrorType As Elad.AlertManagment.Data.Tables.ErrorType;

Property OngoingProblem As %Integer(MAXVAL = 1, MINVAL = 0) [ InitialExpression = ];

Property RepeatingProblem As %Integer(MAXVAL = 1, MINVAL = 0) [ InitialExpression = ];

Property RelatedAlert As Elad.AlertManagment.Data.ManagedAlert;

/// Time at which the alert was recorded at support center.
Property OpenTime As %TimeStamp [ Required ];

/// should be included in the ui , temporary not included
Property OpenTimeOfReportsOfTheSameError As list Of %TimeStamp(STORAGEDEFAULT = "array");

Property CloseTime As %TimeStamp;

/// Total time in hours from open to close
/// dif = ($p($ZDATETIMEH(CloseTime,3),",",1)-$p($ZDATETIMEH(OpenTime,3),",",1))*24 + ((($p($ZDATETIMEH(CloseTime,3),",",2)-$p($ZDATETIMEH(OpenTime,3),",",2)))/3600)
Property TotalTreatmentTime As %Integer [ Calculated, SqlComputeCode = {set {*}=($p($ZDATETIMEH({CloseTime},3),",",1)-$p($ZDATETIMEH({OpenTime},3),",",1))*24 + (($p($ZDATETIMEH({CloseTime},3),",",2)-$p($ZDATETIMEH({OpenTime},3),",",2))/3600)}, SqlComputed ];

/// $e($zdate($ZDATETIMEH(OpenTime,3),8),1,6)
Property YearMonth As %Integer [ Calculated, SqlComputeCode = {set {*}=$e($zdate($ZDATETIMEH({OpenTime},3),8),1,6)}, SqlComputed ];

/// should be included in the ui , temporary not included
/// List of times when this alert was treated
Property TreatmentTime As list Of %TimeStamp(STORAGEDEFAULT = "array");

/// should be included in the ui , temporary not included
/// List of treatments when this alert was treated
/// A treatment from Treatments Table
Property TreatmentsT As list Of Elad.AlertManagment.Data.Tables.Treatment(STORAGEDEFAULT = "array");

/// List of treatments when this alert was treated
/// free text or a
Property TreatmentsF As list Of %String(STORAGEDEFAULT = "array");

/// should be included in the ui , temporary not included
Property StatusOfTreatment As list Of Elad.AlertManagment.Data.Tables.TreatmentStatus(STORAGEDEFAULT = "array");

/// should be included in the ui , temporary not included
Property People As list Of Elad.AlertManagment.Data.Tables.Person(STORAGEDEFAULT = "array");

/// Name of the business host that is sending the alert
Property SourceConfigName As %String(MAXLEN = 128);

/// Text of the alert message
Property AlertText As %String(MAXLEN = "");

/// Field for designating the external destination of this alert message
Property AlertDestination As %String(MAXLEN = "");

/// Time at which the alert was created.
Property AlertTime As Ens.DataType.UTC [ InitialExpression = {$$$timeUTC} ];

/// The session in which the Alert occurred.
Property SessionId As %Integer;

Property Organization As Elad.AlertManagment.Data.Tables.Organization;

Property ThirdParty As Elad.AlertManagment.Data.Tables.ThirdParty;

Property System As Elad.AlertManagment.Data.Tables.System;

/// An numerator for job cards of this alert
Property JobcardNumerator As %Integer [ InitialExpression = 1, Required ];

Property JobCardsLines As list Of Elad.AlertManagment.Data.JobCard.JobCardLine(STORAGEDEFAULT = "array");

Property EscalationType As Elad.AlertManagment.Data.Tables.EscalationType;

Property EscalationTypeLevel As Elad.AlertManagment.Data.Tables.EscalationTypeLevel;

Property RoutCard As list Of Elad.AlertManagment.Data.Tables.RoutCard;

Property ProductionStation As list Of Elad.AlertManagment.Data.Tables.ProductionStation;

/// The Host's Production name in Production
Property HostProduction As %String(MAXLEN = 1000);

/// The Host's name in Production
Property HostName As %String(MAXLEN = 1000);

/// The Host's class name
Property HostClassName As %String(MAXLEN = 1000);

/// Orinited by : Inactivity, System, Other
Property HostType As %String(DISPLAYLIST = ",BS,BP,BO,Production,Rule,DTL,Other", VALUELIST = ",1,2,3,4,5,6,7") [ InitialExpression = ];

Index YearMonthIndex On YearMonth;

Index CloseTimeIndex On CloseTime;

Index OpenTimeIndex On OpenTime;

Index AlertSortIndex On AlertSort;

Index IsOpenIndex On IsOpen [ Type = bitmap ];

Index ManagedAlertIDIndex On ManagedAlertID [ Unique ];

Index OrgBitmap On Organization [ Type = bitmap ];

Index SortBitmap On AlertSort [ Type = bitmap ];

Index AlertTypeBitmap On AlertType [ Type = bitmap ];

Index ErrorTypeBitmap On ErrorType [ Type = bitmap ];

Index OrgAndSort On (Organization, AlertSort);

Index OrgAndYearMonth On (Organization, YearMonth);

/*
ClassMethod IndexOpen(val, concurrency, sc As %Status)
Returns existing object with index value equal to val.
Index ManagedAlertIDIndex On ManagedAlertID [ Unique ];
SET alert = ##class(Elad.AlertManagment.Data.ManagedAlert).ManagedAlertIDIndexOpen("SHE1694",2,.sc)
SET success = ##class(Sample.Person).ManagedAlertIDIndexExists("SHE1694",.id)
*/
Method TotalTreatmentTimeGet() As %Integer
{
set TotalTreatmentTime = ($p($ZDATETIMEH(..CloseTime,3),",",1)-$p($ZDATETIMEH(..OpenTime,3),",",1))*24
set TotalTreatmentTime= TotalTreatmentTime+ ($p($ZDATETIMEH(..CloseTime,3),",",2)-$p($ZDATETIMEH(..OpenTime,3),",",2))/3600
quit TotalTreatmentTime
}

Method YearMonthGet() As %Integer
{
quit $e($zdate($ZDATETIMEH(..OpenTime,3),8),1,6)
}

/// contains Ens.Alerting.NotificationRequest contains Ens.Alerting.ManagedAlert
ClassMethod GetNewID(AlertRequest As Ens.AlertRequest) As %Status
{
//<SourceConfigName>SYSTEM :Prod - sheba - Production:System Message:Prod-sheba-[CACHE SEVERE </SourceConfigName>
//<SourceConfigName>DatexGetFiles DaySurgery : Production - sheba:Elad.Productions.Sheba</SourceConfigName
If $find(AlertRequest.SourceConfigName,"SYSTEM") {
set Hospital=$p(AlertRequest.SourceConfigName,"-",2)
set Hospital=$p(Hospital,"-",1)
}
else {
set Hospital=$p(AlertRequest.SourceConfigName,"-",2)
set Hospital=$p(Hospital,"-",1)
}
set Hospital=$zstrip($zconvert(Hospital,"U"),"<>"," ")
set OrganizationInitials="SUR" // System Un Recognized
set Organization="SUR"
Set tRS = ##class(%ResultSet).%New("Elad.AlertManagment.Data.Tables.Organization:OrganizationByName")
Do tRS.Execute(Hospital)
If tRS.Next() {
Set OrganizationInitials = tRS.Data("OrganizationInitials")
Set Organization=tRS.Data("OrganizationID")
}
set Update=0
//-------------------------------------------------------------???
Set tFoundID = 0
&sql(SELECT TOP 1 ID INTO :tFoundID
FROM Elad_AlertManagment_Data.ManagedAlert
WHERE (SourceConfigName  = :AlertRequest.SourceConfigName
AND AlertText = :AlertRequest.AlertText
AND AlertDestination = :AlertRequest.AlertDestination)
ORDER BY ID ASC
)
Set ID = tFoundID
//----------------------------------------------------------------
If $get(ID) set Update=1
/// Building Data Managed Alert
/// New alert
if 'Update {
//set ID=OrganizationInitials_$i(^Elad.AlertMan669B.ManagedAlertD)
set obj=##class(Elad.AlertManagment.Data.ManagedAlert).%New()
set ID=obj.%Id()
}
/// Repeating alert
if Update {
set obj=##class(Elad.AlertManagment.Data.ManagedAlert).%OpenId(ID)
}

if '##class(%Library.TimeStamp).IsValid(AlertRequest.AlertTime) set AlertRequest.AlertTime=$zdt($h,3)
/// Update alert
set obj.AlertDestination=AlertRequest.AlertDestination
set obj.AlertText=AlertRequest.AlertText
set obj.AlertTime=AlertRequest.AlertTime
set obj.SessionId=AlertRequest.SessionId
set obj.SourceConfigName=AlertRequest.SourceConfigName
if 'Update {
set obj.ManagedAlertID=OrganizationInitials_($o(^Elad.AlertMan669B.ManagedAlertD(""),-1)+1)
set obj.NumberOfReportsOfTheSameError=1
set obj.OpenTime=AlertRequest.AlertTime
do obj.OpenTimeOfReportsOfTheSameError.SetAt(AlertRequest.AlertTime,1)
set obj.OriginalAlertSessionId=AlertRequest.SessionId
OrganizationObj=##class(Elad.AlertManagment.Data.Tables.Organization).%OpenId(Organization)
if OrganizationObj'="" set obj.Organization=OrganizationObj
}
if Update {
set obj.NumberOfReportsOfTheSameError=$i(obj.NumberOfReportsOfTheSameError)
do obj.OpenTimeOfReportsOfTheSameError.SetAt(AlertRequest.AlertTime,(obj.OpenTimeOfReportsOfTheSameError.Count()+1))
set obj.RepeatingProblem=1
}
SET obj.AlertSort=##class(Elad.AlertManagment.Data.Tables.AlertSort).%New()
set obj.AlertSort.AlertSortID=$S($find(obj.AlertText,"Inactivity timeout"):1,$find(obj.SourceConfigName,"SYSTEM :"):2,1:3)
//s ^simcha($zd($h,8),$i(i))="obj.%Id():"_obj.%Id()_"_Update:"_Update_"_tFoundID:"_tFoundID

if '##class(%Library.TimeStamp).IsValid(obj.OpenTime) set obj.OpenTime=$zdt($h,3)
set st=obj.%Save()
set ind=$o(^sghp1(""),-1)
set ^sghp1($i(ind))=st_"**"_Hospital_"**"_OrganizationInitials_"**"_Organization_"**"_obj.SourceConfigName_"!!!"_obj.AlertText_"!!!"_obj.AlertDestination_"!!!"_obj.AlertTime_"!!!"_obj.SessionId

quit st
}

/// <p>This is a system provided query that returns a row for each instance within this extent. The first column of the row is the
/// object ID. Additional columns can be included in the select list by adding the desired columns to the <parameter>EXTENTQUERYSPEC</parameter> parameter.</p>
/// <p>
/// The Extent query default implementation is generated by <class>%Library.ExtentSQLQuery</class>. That class
/// supports the <var>COMPILEMODE</var> parameter with possible values of IMMEDIATE and DYNAMIC. If DYNAMIC is specified
/// then the SQL statement used to implement the query will be generated as a dynamic SQL statement. If IMMEDIATE is specified
/// then the statement is generated as an embedded SQL statement.</p>
/// <br><p>This query can be overridden by a subclass so long as two requirements are met. The list of columns must include %ID as the first column and
/// it must return a row corresponding to each instance/row in the extent.</p>
Query Extent() As %ExtentSQLQuery(CONTAINID = 1) [ SqlProc ]
{
}

/// general Alert Display
Query Alert() As %SQLQuery(CONTAINID = 8)
{
SELECT AlertDestination,AlertText,AlertTime,AlertType->AlertTypeDescription,CloseTime,ErrorType->ErrorTypeDescription,ManagedAlertID,%ID,OpenTime,Organization->OrganizationDescriptionEnglish,SessionId,SourceConfigName FROM ManagedAlert
 ORDER BY OpenTime
}

/// find alert by ManagedAlertID
Query AlertByManagedAlertID(ManagedAlertID As %String) As %SQLQuery(CONTAINID = 1)
{
SELECT %ID,ManagedAlertID FROM ManagedAlert
 WHERE (JobcardNumerator = :ManagedAlertID)
}

/// List of all alerts -0:Open,1:Closed,2:All
Query AlertByOpen(Open As %Integer = 1) As %SQLQuery(CONTAINID = 1)
{
SELECT %ID,ManagedAlertID,AlertText FROM ManagedAlert
 WHERE (IsOpen NOT= :Open)
}

/// Open Alerts between dates
Query OpenAlertsBetweendates(FromDate As %TimeStamp, ToDate As %TimeStamp) As %SQLQuery(CONTAINID = 1)
{
SELECT %ID,ManagedAlertID,AlertText,AlertTime,IsOpen FROM ManagedAlert
 WHERE (AlertTime BETWEEN :FromDate AND :ToDate AND IsOpen = 1)
 ORDER BY ManagedAlertID
}

/// By Sort
Query AlertBySort(Sort As %Integer = 2, Open As %Integer = 1) As %SQLQuery(CONTAINID = 1)
{
SELECT %ID,ManagedAlertID,AlertText,AlertSort FROM ManagedAlert
 WHERE (AlertSort = :Sort AND IsOpen = :Open)
 ORDER BY ManagedAlertID
}

/// By Organization
Query AlertListByOrganization(Org As Elad.AlertManagment.Data.Tables.Organization, Open As %Integer = 1) As %SQLQuery(CONTAINID = 1)
{
SELECT %ID,ManagedAlertID,AlertText,AlertTime,OpenTime FROM Elad_AlertManagment_Data.ManagedAlert WHERE (Organization->OrganizationID = :Org AND IsOpen = :Open)
 ORDER BY OpenTime DESC
}

/// By Organization/Sort
Query AlertByOrganizationSort(Org As Elad.AlertManagment.Data.Tables.Organization, Sort As %Integer = 2, Open As %Integer = 1) As %SQLQuery(CONTAINID = 1)
{
SELECT %ID,ManagedAlertID,AlertText,AlertTime,OpenTime,AlertSort FROM Elad_AlertManagment_Data.ManagedAlert WHERE (Organization->OrganizationID = :Org AND AlertSort = :Sort AND IsOpen = :Open)
 ORDER BY OpenTime DESC
}

/// By Organization/Date
Query AlertByOrganizationDate(Org As Elad.AlertManagment.Data.Tables.Organization, FromDate As %TimeStamp, ToDate As %TimeStamp, Open As %Integer = 1) As %SQLQuery(CONTAINID = 1)
{
SELECT %ID,ManagedAlertID,AlertText,AlertTime,OpenTime,AlertSort FROM Elad_AlertManagment_Data.ManagedAlert WHERE (Organization->OrganizationID = :Org  AND AlertTime BETWEEN :FromDate AND :ToDate  AND IsOpen = :Open)
 ORDER BY OpenTime DESC
}

/// By Organization/Sort/Date
Query AlertByOrganizationSortDate(Org As Elad.AlertManagment.Data.Tables.Organization, Sort As %Integer = 2, FromDate As %TimeStamp, ToDate As %TimeStamp, Open As %Integer = 1) As %SQLQuery(CONTAINID = 1)
{
SELECT %ID,ManagedAlertID,AlertText,AlertTime,OpenTime,AlertSort FROM Elad_AlertManagment_Data.ManagedAlert WHERE (Organization->OrganizationID = :Org AND AlertSort = :Sort AND AlertTime BETWEEN :FromDate AND :ToDate  AND IsOpen = :Open)
 ORDER BY OpenTime DESC
}

Query AlertByType(TypeID As Elad.AlertManagment.Data.Tables.AlertType, Open As %Integer = 1) As %SQLQuery(CONTAINID = 1)
{
SELECT %ID,AlertText,AlertTime FROM Elad_AlertManagment_Data.ManagedAlert
 WHERE ( AlertType->AlertTypeID= :TypeID AND IsOpen = :Open)
}

Query AlertByErrorType(TypeID As Elad.AlertManagment.Data.Tables.ErrorType, Open As %Integer = 1) As %SQLQuery(CONTAINID = 1)
{
SELECT %ID,AlertText,AlertTime FROM Elad_AlertManagment_Data.ManagedAlert
 WHERE ( ErrorType->ErrorTypeID= :TypeID AND IsOpen = :Open)
}

Query AlertByPerson(TypeID As Elad.AlertManagment.Data.Tables.Person) As %SQLQuery(CONTAINID = 1)
{
SELECT a.%ID FROM Elad_AlertManagment_Data.ManagedAlert_People INNER JOIN Elad_AlertManagment_Data_Tables.Person b
 ON (a.People=b.PersonId)
 WHERE ( b.PersonId = :TypeID )
}

// TreatmentsT As list Of Elad.AlertManagment.Data.Tables.Treatment

Query AlertByTreatment(TypeID As Elad.AlertManagment.Data.Tables.Treatment) As %SQLQuery(CONTAINID = 1)
{
SELECT a.%ID FROM Elad_AlertManagment_Data.ManagedAlert_TreatmentsT INNER JOIN Elad_AlertManagment_Data_Tables.Treatment b
 ON (a.TreatmentsT=b.TreatmentID)
 WHERE ( b.TreatmentID = :TypeID)
}

/// finding organizations where their average treatment time of an alert is more than the average
Query TreatmentTimeByOrganizationOverAverage() As %SQLQuery(CONTAINID = 1)
{
SELECT Organization->OrganizationDescriptionEnglish,TotalTreatmentTime || AVG(TotalTreatmentTime) AS AverageTotalTreatmentTime
     FROM Elad_AlertManagment_Data.ManagedAlert
GROUP BY Organization->OrganizationDescriptionEnglish
     HAVING TotalTreatmentTime>AVG(TotalTreatmentTime)
}

/// Average & var monthly treatment time
Query TreatmentTimeByYearMonthAverage() As %SQLQuery(CONTAINID = 1)
{
SELECT YearMonth,TotalTreatmentTime || AVG(TotalTreatmentTime) AS AverageTotalTreatmentTime, VARIANCE(TotalTreatmentTime) AS TotalTreatmentTimeVar
     FROM Elad_AlertManagment_Data.ManagedAlert
GROUP BY YearMonth
}

/// Average treatment time By Error Type
Query AverageTreatmentTimeByErrorType() As %SQLQuery(CONTAINID = 1)
{
SELECT ErrorType->ErrorTypeDescription,TotalTreatmentTime || AVG(TotalTreatmentTime) AS AverageTotalTreatmentTime
     FROM Elad_AlertManagment_Data.ManagedAlert
GROUP BY ErrorType->ErrorTypeDescription
}

Query AlertCountByOrganizationSort() As %SQLQuery
{
SELECT DISTINCT COUNT(*) AS mynum,AlertSort,Organization->OrganizationID AS Organization FROM ManagedAlert
GROUP BY Organization,AlertSort
ORDER BY Organization
}

Query AlertCountByOrganizationSortYearMonth(Organization, Open As %Integer = 1) As %SQLQuery
{
SELECT  DISTINCT COUNT(*) AS mynum,YearMonth,AlertSort,Organization->OrganizationID AS Organization FROM ManagedAlert
WHERE (Organization->OrganizationID  = :Organization AND IsOpen = :Open)
GROUP BY YearMonth,AlertSort
ORDER BY AlertSort
}

// WHERE SourceConfigName = :AlertRequest.SourceConfigName

Query AlertCountByOrganization() As %SQLQuery
{
SELECT DISTINCT COUNT(*) AS mynum,Organization->OrganizationID AS Organization FROM ManagedAlert
GROUP BY Organization
ORDER BY Organization
}

Query AlertCountByOrganizationYearMonth() As %SQLQuery
{
SELECT DISTINCT COUNT(*) AS mynum,YearMonth,Organization->OrganizationID AS Organization FROM ManagedAlert
GROUP BY Organization,YearMonth
ORDER BY Organization
}

/// Calculates the average budget deviation avg(ErrorType->BudgeTime-TotalTreatmentTime)
Query BudgetDeviationByErrorType() As %SQLQuery
{
SELECT TotalTreatmentTime,ErrorType->ErrorTypeID AS ErrorTypeID ,ErrorType->BudgeTime || AVG(ErrorType->BudgeTime-TotalTreatmentTime) AS AverageTreatmentDeviation FROM ManagedAlert
GROUP BY ErrorType->ErrorTypeID
ORDER BY ErrorType->ErrorTypeID
}

/// Calculates the average budget deviation avg(ErrorType->BudgeTime-TotalTreatmentTime)
Query BudgetDeviationByOrganization() As %SQLQuery
{
SELECT Organization->OrganizationID AS Organization,TotalTreatmentTime,ErrorType->ErrorTypeID AS ErrorTypeID  ,ErrorType->BudgeTime || AVG(ErrorType->BudgeTime-TotalTreatmentTime) AS AverageTreatmentDeviation FROM ManagedAlert
GROUP BY Organization,ErrorType->ErrorTypeID
ORDER BY Organization,ErrorType->ErrorTypeID
}

/// contains Ens.Alerting.NotificationRequest contains Ens.Alerting.ManagedAlert
Storage Default
{
<Data name="JobCardsLines">
<Attribute>JobCardsLines</Attribute>
<Structure>subnode</Structure>
<Subscript>"JobCardsLines"</Subscript>
</Data>
<Data name="ManagedAlertDefaultData">
<Value name="1">
<Value>%%CLASSNAME</Value>
</Value>
<Value name="2">
<Value>ManagedAlertID</Value>
</Value>
<Value name="3">
<Value>RepreatingProblem</Value>
</Value>
<Value name="4">
<Value>RelatedAlert</Value>
</Value>
<Value name="5">
<Value>OngoingProblem</Value>
</Value>
<Value name="6">
<Value>OpenTime</Value>
</Value>
<Value name="7">
<Value>AlertType</Value>
</Value>
<Value name="8">
<Value>ManagedAlert</Value>
</Value>
<Value name="9">
<Value>NotificationType</Value>
</Value>
<Value name="10">
<Value>AlertDestinations</Value>
</Value>
<Value name="11">
<Value>ErrorType</Value>
</Value>
<Value name="12">
<Value>RepeatingProblem</Value>
</Value>
<Value name="13">
<Value>OriginalAlertID</Value>
</Value>
<Value name="14">
<Value>NumberOfReportsOfTheSameError</Value>
</Value>
<Value name="15">
<Value>OriginalAlertSessionId</Value>
</Value>
<Value name="16">
<Value>AlertRequest</Value>
</Value>
<Value name="17">
<Value>SourceConfigName</Value>
</Value>
<Value name="18">
<Value>AlertText</Value>
</Value>
<Value name="19">
<Value>AlertDestination</Value>
</Value>
<Value name="20">
<Value>AlertTime</Value>
</Value>
<Value name="21">
<Value>SessionId</Value>
</Value>
<Value name="22">
<Value>IsOpen</Value>
</Value>
<Value name="23">
<Value>CloseTime</Value>
</Value>
<Value name="24">
<Value>Organization</Value>
</Value>
<Value name="25">
<Value>ThirdParty</Value>
</Value>
<Value name="26">
<Value>System</Value>
</Value>
<Value name="27">
<Value>AlertSort</Value>
</Value>
<Value name="28">
<Value>JobcardNumerator</Value>
</Value>
<Value name="29">
<Value>JobCards</Value>
</Value>
<Value name="30">
<Value>TotalTreatmentTime</Value>
</Value>
<Value name="31">
<Value>YearMonth</Value>
</Value>
<Value name="32">
<Value>EscalationType</Value>
</Value>
<Value name="33">
<Value>EscalationTypeLevel</Value>
</Value>
<Value name="34">
<Value>RootCard</Value>
</Value>
<Value name="35">
<Value>ProductionStation</Value>
</Value>
<Value name="36">
<Value>RoutCard</Value>
</Value>
<Value name="37">
<Value>HostName</Value>
</Value>
<Value name="38">
<Value>HostClassName</Value>
</Value>
<Value name="39">
<Value>HostType</Value>
</Value>
<Value name="40">
<Value>HostProduction</Value>
</Value>
</Data>
<Data name="OpenTimeOfRepeatingError">
<Attribute>OpenTimeOfRepeatingError</Attribute>
<Structure>subnode</Structure>
<Subscript>"OpenTimeOfRepeatingError"</Subscript>
</Data>
<Data name="OpenTimeOfReportsOfTheSameError">
<Attribute>OpenTimeOfReportsOfTheSameError</Attribute>
<Structure>subnode</Structure>
<Subscript>"OpenTimeOfReportsOfTheSameError"</Subscript>
</Data>
<Data name="People">
<Attribute>People</Attribute>
<Structure>subnode</Structure>
<Subscript>"People"</Subscript>
</Data>
<Data name="StatusOfTreatment">
<Attribute>StatusOfTreatment</Attribute>
<Structure>subnode</Structure>
<Subscript>"StatusOfTreatment"</Subscript>
</Data>
<Data name="Treatment">
<Attribute>Treatment</Attribute>
<Structure>subnode</Structure>
<Subscript>"Treatment"</Subscript>
</Data>
<Data name="TreatmentTime">
<Attribute>TreatmentTime</Attribute>
<Structure>subnode</Structure>
<Subscript>"TreatmentTime"</Subscript>
</Data>
<Data name="Treatments">
<Attribute>Treatments</Attribute>
<Structure>subnode</Structure>
<Subscript>"Treatments"</Subscript>
</Data>
<Data name="TreatmentsF">
<Attribute>TreatmentsF</Attribute>
<Structure>subnode</Structure>
<Subscript>"TreatmentsF"</Subscript>
</Data>
<Data name="TreatmentsT">
<Attribute>TreatmentsT</Attribute>
<Structure>subnode</Structure>
<Subscript>"TreatmentsT"</Subscript>
</Data>
<DataLocation>^Elad.AlertMan669B.ManagedAlertD</DataLocation>
<DefaultData>ManagedAlertDefaultData</DefaultData>
<Description>
<![CDATA[contains Ens.Alerting.NotificationRequest contains Ens.Alerting.ManagedAlert]]></Description>
<ExtentSize>1583</ExtentSize>
<IdLocation>^Elad.AlertMan669B.ManagedAlertD</IdLocation>
<IndexLocation>^Elad.AlertMan669B.ManagedAlertI</IndexLocation>
<SQLMap name="AlertSortIndex">
<BlockCount>-8</BlockCount>
</SQLMap>
<SQLMap name="CloseTimeIndex">
<BlockCount>-12</BlockCount>
</SQLMap>
<SQLMap name="IDKEY">
<BlockCount>-372</BlockCount>
</SQLMap>
<SQLMap name="IsOpenIndex">
<BlockCount>-12</BlockCount>
</SQLMap>
<SQLMap name="ManagedAlertIDIndex">
<BlockCount>-16</BlockCount>
</SQLMap>
<SQLMap name="OpenTimeIndex">
<BlockCount>-16</BlockCount>
</SQLMap>
<SQLMap name="YearMonthIndex">
<BlockCount>-8</BlockCount>
</SQLMap>
<StreamLocation>^Elad.AlertMan669B.ManagedAlertS</StreamLocation>
<Type>%Library.CacheStorage</Type>
}

}