KMPUTLW2 ;SP/JML - Manage REST interfaces for VSM Monitors ;11/1/2023
;;4.0;CAPACITY MANAGEMENT;**1,4**;3/1/2018;Build 36
;
; Reference to ^%ZTER(1 supported by ICR #7138
; Reference to ^%ZTER(3.077 supported by ICR #7139
;
EVTPKG(KMPOPT) ;
; calculate eventname, parenteventname, eventtype, eventsource
N KMPENAME,KMPESTR,KMPPSTR
S KMPESTR="|||",KMPPSTR="|"
S KMPESTR=$$CALCEVT(KMPOPT)
S KMPENAME=$P(KMPESTR,"|")
;
S KMPPSTR=$G(^KMPVPKG(KMPENAME))
I KMPPSTR="" D
.S KMPPSTR=$$CALCPKG(KMPENAME)
Q KMPESTR_"|"_KMPPSTR
;
CALCEVT(KMPOPT) ;
N KMPENAM,KMPETYP,KMPP1,KMPP2,KMPPENAM,KMPRUMD
S (KMPENAM,KMPPENAM,KMPETYP,KMPRUMD)=""
S KMPP1=$P(KMPOPT,"***"),KMPP2=$P(KMPOPT,"***",2)
; Event Type - RPC, Protocol, Option
S KMPETYP=$S($E(KMPP1)="`":"RPC",KMPP2'="":"PROTOCOL",1:"OPTION")
; RUM Designation -> EventSource - 1:TaskMan, 2: Menu, 3:RPC Broker, 4:Users, 5:Unknown
I $E(KMPP1)="!"!(KMPP1="$AFTR ZTMS$")!(KMPP1="$STRT ZTMS$") S KMPRUMD="TASKMAN"
I KMPRUMD="" S KMPRUMD=$S($E(KMPP1)="`":"RPC BROKER",$E(KMPP1)="#":"USERS",1:"MENU")
I KMPRUMD="" S KMPRUMD="UNKNOWN"
; EventName
I $$RESERVED(KMPP1) S KMPENAM=KMPP1 ; handle system events
I KMPENAM="","`!#"[$E(KMPP1) S KMPENAM=$E(KMPP1,2,$L(KMPP1)) ; handle non menu events
I KMPENAM="" S KMPENAM=KMPP1 ; remaining need no editing
I KMPP2'="" S KMPPENAM=KMPENAM,KMPENAM=KMPP2 ; IF PROTOCOL SET OPTION AS PARENT EVENT
I (KMPENAM'="")&($E(KMPENAM,1)="`") S KMPENAM=$E(KMPENAM,2,$L(KMPENAM))
S KMPRET=KMPENAM_"|"_KMPPENAM_"|"_KMPETYP_"|"_KMPRUMD
S ^KMPVEVT(KMPOPT)=KMPRET
Q KMPRET
;
CALCPKG(KMPENAME) ;
N KMPIEN,KMPPKGID,KMPPNAM,KMPPRE,KMPRET
; CODE FROM SERVER TO SET KMPPKGID
I $$RESERVED(KMPENAME) Q $$RESPACK(KMPENAME)
S KMPPKGID="",KMPRET="UNKNOWN^UNKNOWN"
S KMPPRE=$E(KMPENAME,1,4) D
.I $D(^DIC(9.4,"C",KMPPRE)) S KMPPKGID=$O(^DIC(9.4,"C",KMPPRE,""))
I KMPPKGID="" S KMPPRE=$E(KMPENAME,1,3) D
.I $D(^DIC(9.4,"C",KMPPRE)) S KMPPKGID=$O(^DIC(9.4,"C",KMPPRE,""))
I KMPPKGID="" S KMPPRE=$E(KMPENAME,1,2) D
.I $D(^DIC(9.4,"C",KMPPRE)) S KMPPKGID=$O(^DIC(9.4,"C",KMPPRE,""))
I KMPPKGID="" Q KMPRET
S KMPIEN=""
; IF 2 ENTRIES NO WAY TO DECIDE WHICH IS CORRECT SO TAKE FIRST - DON'T LOOP - RARE OCCURRENCE
S KMPIEN=$O(^DIC(9.4,"C",KMPPRE,KMPIEN)) Q:KMPIEN="" D
.S KMPPNAM=$P($G(^DIC(9.4,KMPIEN,0)),"^")
.S KMPRET=KMPPRE_"|"_KMPPNAM
.S ^KMPVPKG(KMPENAME)=KMPRET
Q KMPRET
;
RESERVED(KMPENAME) ; Return 1 if system event
I "#USER#^$AFTR ZTMS$^$STRT ZTMS$^$BROKER HANDLER$^$LOGIN$^$VISTALINK HANDLER$^$XQ MENU DRIVER$^EVE^"[KMPENAME Q 1
I "#USER#^$AFTR ZTMS$^$STRT ZTMS$^$BROKER HANDLER$^$LOGIN$^$VISTALINK HANDLER$^$XQ MENU DRIVER$"[$E(KMPENAME,2,$L(KMPENAME)) Q 1
Q 0
;
RESPACK(KMPENAME) ; Return PREFIX^PACKAGE
I "^$AFTR ZTMS$^$STRT ZTMS$^$XQ MENU DRIVER$^$LOGIN$^#USER#^EVE^"[KMPENAME Q "XU|KERNEL"
I "^$BROKER HANDLER$^"[KMPENAME Q "XWB|RPC BROKER"
I "^$VISTALINK HANDLER$^"[KMPENAME Q "XOBV|VISTALINK"
; The following code is to fix null vsmpackage in KMPVBusinessEvent 2-14-2018 SCL
I "^$BROKER HANDLER$^"[$E(KMPENAME,2,$L(KMPENAME)) Q "XWB|RPC BROKER"
I "^$AFTR ZTMS$^$STRT ZTMS$^$XQ MENU DRIVER$^$LOGIN$^#USER#^EVE^"[$E(KMPENAME,2,$L(KMPENAME)) Q "XU|KERNEL"
I "^$VISTALINK HANDLER$^"[$E(KMPENAME,2,$L(KMPENAME)) Q "XOBV|VISTALINK"
Q ""
;
SETCFG(KMPCFG) ; Change VSM configuration via national server change request
N KMPDATA,KMPEARR,KMPENUM,KMPFNAM,KMPFNUM,KMPFUNC,KMPFVAL,KMPI,KMPIEN,KMPMKEY,KMPMSG,KMPMSG2,KMPON,KMPRESP,KMPRT
N KMPRTN,KMPRTO,KMPTEXT,KMPTNUM,KMPVER,FDA
;
S KMPFUNC="SETCFG"
S KMPMKEY=KMPCFG.Monitor
S (KMPMSG,KMPMSG2)=""
;
D STOPMON^KMPVCBG(KMPMKEY,1,1)
;
S KMPVER=$$GETVAL^KMPVCCFG(KMPMKEY,"VERSION",8969)
I KMPCFG.Function'="SetConfig" Q "Incorrect Function Type"
S KMPFVAL("ALLOW TEST SYSTEM")=KMPCFG.AllowTestSystem
S KMPFVAL("APIKEY")=KMPCFG.ApiKey
S KMPFVAL("COLLECTION INTERVAL")=KMPCFG.CollectionInterval
S KMPFVAL("DAYS TO KEEP DATA")=KMPCFG.DaysToKeepData
S KMPFVAL("ENCRYPT")=KMPCFG.Encrypt
S KMPFVAL("HTTP REQUEST MAX LENGTH")=KMPCFG.HttpRequestMaxLength
S KMPFVAL("MONITOR START DELAY")=KMPCFG.MonitorStartDelay
S KMPFVAL("NATIONAL DATA EMAIL ADDRESS")=KMPCFG.NationalDataEmailAddress
S KMPFVAL("NATIONAL FQDN")=KMPCFG.NationalFqdn
S KMPFVAL("NATIONAL IP ADDRESS")=KMPCFG.NationalIpAddress
S KMPFVAL("NATIONAL PORT")=KMPCFG.NationalPort
S KMPFVAL("NATIONAL SUPPORT EMAIL ADDRESS")=KMPCFG.NationalSupportEmailAddress
S KMPFVAL("ONOFF")=KMPCFG.OnOff
S KMPFVAL("TASKMAN OPTION")=KMPCFG.TaskmanOption
S KMPFVAL("VSM CFG EMAIL ADDRESS")=KMPCFG.VsmCfgEmailAddress
;
; verify Monitor Type is valid
I $D(^KMPV(8969,"B",KMPMKEY)) S KMPIEN=$O(^KMPV(8969,"B",KMPMKEY,""))
I $G(KMPIEN)="" Q "Monitor "_KMPMKEY_" not defined. No changes made."
; get field numbers and set FDA array
S KMPFNAM=""
F S KMPFNAM=$O(KMPFVAL(KMPFNAM)) Q:KMPFNAM="" D
.S KMPFNUM=$$FLDNUM^DILFD(8969,KMPFNAM)
.I KMPFNUM>0 S FDA($J,8969,KMPIEN_",",KMPFNUM)=KMPFVAL(KMPFNAM)
.E S KMPEARR(KMPFNAM)=""
;
; If field name does not exist send message and quit
I $D(KMPEARR) D Q "Configuration Update field(s) do not exist in the VSM CONFIGURATION file"
.S KMPTEXT("SUBJECT")="VSM ALERT: Configuration Update field(s) do not exist in the VSM CONFIGURATION file "
.S KMPI=1
.S KMPFNAM="",KMPTEXT(KMPI)=KMPMKEY_" Missing Fields",KMPI=KMPI+1
.F S KMPFNAM=$O(KMPEARR(KMPFNAM)) Q:KMPFNAM="" D
..S KMPTEXT(KMPI)=KMPFNAM,KMPI=KMPI+1
;
; If still good get old values for logging changes
S KMPFNAM=""
F S KMPFNAM=$O(KMPFVAL(KMPFNAM)) Q:KMPFNAM="" D
.S $P(KMPFVAL(KMPFNAM),"^",2)=$$GETVAL^KMPVCCFG(KMPMKEY,KMPFNAM,8969,"I")
;
; ATTEMPT TO MAKE CHANGES
K KMPEARR
D FILE^DIE("ET","FDA($J)","KMPEARR")
; IF ERRORS SEND MESSAGE WITH ERRORS
S KMPRESP="OK"
S KMPI=1
I $D(KMPEARR) D ; Add filing errors to support message
.S KMPRESP="UPDATE FAILED"
.S KMPTEXT("SUBJECT")="VSM ALERT:"_KMPMKEY_" Configuration Update: WITH ERRORS. "
.S KMPTEXT(KMPI)="Changes NOT applied to VSM CONFIGURATION file. ",KMPI=KMPI+1
.S KMPTEXT(KMPI)="Number of errors: "_+KMPEARR("DIERR"),KMPI=KMPI+1
.S KMPENUM=""
.F S KMPENUM=$O(KMPEARR("DIERR",KMPENUM)) Q:+KMPENUM=0 D
..S KMPTNUM=""
..F S KMPTNUM=$O(KMPEARR("DIERR",KMPENUM,"TEXT",KMPTNUM)) Q:+KMPTNUM=0 D
...S KMPTEXT(KMPI)=KMPEARR("DIERR",KMPENUM,"TEXT",KMPTNUM),KMPI=KMPI+1
.D INFOMSG^KMPUTLW(.KMPTEXT)
; If no FILING errors then list changes in Support Message and Log Changes
I '$D(KMPEARR) D
.S KMPI=1
.S KMPTEXT("SUBJECT")="VSM CONFIGURATION: "_KMPMKEY_" Configuration Update: No Errors. "
.S KMPTEXT(KMPI)="Changes applied to VSM CONFIGURATION file. ",KMPI=KMPI+1
.; list changes in Support Message
.S KMPFNAM="",KMPTEXT(KMPI)="Changed Fields",KMPI=KMPI+1
.F S KMPFNAM=$O(KMPFVAL(KMPFNAM)) Q:KMPFNAM="" D
..S KMPDATA=KMPFVAL(KMPFNAM)
..S KMPTEXT(KMPI)=KMPFNAM_"-"_$P(KMPDATA,"^",2)_" TO "_$P(KMPDATA,"^"),KMPI=KMPI+1
.D INFOMSG^KMPUTLW(.KMPTEXT)
; if end state is 'ON' then start monitor
I $$GETVAL^KMPVCCFG(KMPMKEY,"ONOFF",8969)="ON" D STARTMON^KMPVCBG(KMPMKEY,1,1)
;
Q KMPRESP
;
GETERR(KMPRET,KMPREQ) ; Return run history recorded in the VSM CACHE TASK LOG file
N KMPD,KMPDAT,KMPENUM,KMPINODE,KMPJNODE,KMPUVNB,KMPVAL,KMPVAR,KMPVNUM,KMPVOBJ
;
S KMPDAT=KMPREQ.ErrorDate
I KMPDAT="" S KMPRET.Status="No Date Provided" Q
S KMPDAT=$ZDATEH(KMPDAT,3)
S KMPENUM=KMPREQ.ErrorNumber
I KMPENUM="" S KMPRET.Status="No Error Number Provided" Q
S KMPD=##class(%DynamicObject).%New()
I '$D(^%ZTER(1,KMPDAT,1,KMPENUM)) S KMPRET.Status="Error Not Found" Q
S KMPD.ErrorNumber=+$G(^%ZTER(1,KMPDAT,1,KMPENUM,0))
S KMPD.LastGlobalReference=$G(^%ZTER(1,KMPDAT,1,KMPENUM,"GR"))
S KMPINODE=$G(^%ZTER(1,KMPDAT,1,KMPENUM,"I"))
S KMPD.CurrentIo=$P(KMPINODE,"^",1)
S KMPD.ZaValue=$P(KMPINODE,"^",2)
S KMPD.ZbValue=$P(KMPINODE,"^",3)
S KMPD.CurrentZio=$P(KMPINODE,"^",4)
S KMPD.HValue=$G(^%ZTER(1,KMPDAT,1,KMPENUM,"H"))
S KMPJNODE=$G(^%ZTER(1,KMPDAT,1,KMPENUM,"J"))
S KMPD.JobNumber=$P(KMPJNODE,"^",1)
S KMPD.ProcessName=$P(KMPJNODE,"^",2)
S KMPD.UserName=$P(KMPJNODE,"^",3)
S KMPUVNB=$P(KMPJNODE,"^",4)
S KMPD.Uci=$P(KMPUVNB,"~",1)
S KMPD.Vol=$P(KMPUVNB,"~",1)
S KMPD.Node=$P(KMPUVNB,"~",1)
S KMPD.Box=$P(KMPUVNB,"~",1)
S KMPD.AlternateJobNumber=$P(KMPJNODE,"^",5)
S KMPD.Line=$G(^%ZTER(1,KMPDAT,1,KMPENUM,"LINE"))
S KMPD.ZE=$G(^%ZTER(1,KMPDAT,1,KMPENUM,"ZE"))
S KMPVNUM=0,KMPVOBJ=##class(%DynamicObject).%New()
F S KMPVNUM=$O(^%ZTER(1,KMPDAT,1,KMPENUM,"ZV",KMPVNUM)) Q:+KMPVNUM=0 D
.S KMPVAR=^%ZTER(1,KMPDAT,1,KMPENUM,"ZV",KMPVNUM,0)
.S KMPVAL=^%ZTER(1,KMPDAT,1,KMPENUM,"ZV",KMPVNUM,"D")
.D KMPVOBJ.%Set(KMPVAR,KMPVAL)
S KMPD.Variables=KMPVOBJ
S KMPRET.Status="Error Found"
S KMPRET.Error=KMPD
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HKMPUTLW2 8833 printed Nov 22, 2024@16:52:10 Page 2
KMPUTLW2 ;SP/JML - Manage REST interfaces for VSM Monitors ;11/1/2023
+1 ;;4.0;CAPACITY MANAGEMENT;**1,4**;3/1/2018;Build 36
+2 ;
+3 ; Reference to ^%ZTER(1 supported by ICR #7138
+4 ; Reference to ^%ZTER(3.077 supported by ICR #7139
+5 ;
EVTPKG(KMPOPT) ;
+1 ; calculate eventname, parenteventname, eventtype, eventsource
+2 NEW KMPENAME,KMPESTR,KMPPSTR
+3 SET KMPESTR="|||"
SET KMPPSTR="|"
+4 SET KMPESTR=$$CALCEVT(KMPOPT)
+5 SET KMPENAME=$PIECE(KMPESTR,"|")
+6 ;
+7 SET KMPPSTR=$GET(^KMPVPKG(KMPENAME))
+8 IF KMPPSTR=""
Begin DoDot:1
+9 SET KMPPSTR=$$CALCPKG(KMPENAME)
End DoDot:1
+10 QUIT KMPESTR_"|"_KMPPSTR
+11 ;
CALCEVT(KMPOPT) ;
+1 NEW KMPENAM,KMPETYP,KMPP1,KMPP2,KMPPENAM,KMPRUMD
+2 SET (KMPENAM,KMPPENAM,KMPETYP,KMPRUMD)=""
+3 SET KMPP1=$PIECE(KMPOPT,"***")
SET KMPP2=$PIECE(KMPOPT,"***",2)
+4 ; Event Type - RPC, Protocol, Option
+5 SET KMPETYP=$SELECT($EXTRACT(KMPP1)="`":"RPC",KMPP2'="":"PROTOCOL",1:"OPTION")
+6 ; RUM Designation -> EventSource - 1:TaskMan, 2: Menu, 3:RPC Broker, 4:Users, 5:Unknown
+7 IF $EXTRACT(KMPP1)="!"!(KMPP1="$AFTR ZTMS$")!(KMPP1="$STRT ZTMS$")
SET KMPRUMD="TASKMAN"
+8 IF KMPRUMD=""
SET KMPRUMD=$SELECT($EXTRACT(KMPP1)="`":"RPC BROKER",$EXTRACT(KMPP1)="#":"USERS",1:"MENU")
+9 IF KMPRUMD=""
SET KMPRUMD="UNKNOWN"
+10 ; EventName
+11 ; handle system events
IF $$RESERVED(KMPP1)
SET KMPENAM=KMPP1
+12 ; handle non menu events
IF KMPENAM=""
IF "`!#"[$EXTRACT(KMPP1)
SET KMPENAM=$EXTRACT(KMPP1,2,$LENGTH(KMPP1))
+13 ; remaining need no editing
IF KMPENAM=""
SET KMPENAM=KMPP1
+14 ; IF PROTOCOL SET OPTION AS PARENT EVENT
IF KMPP2'=""
SET KMPPENAM=KMPENAM
SET KMPENAM=KMPP2
+15 IF (KMPENAM'="")&($EXTRACT(KMPENAM,1)="`")
SET KMPENAM=$EXTRACT(KMPENAM,2,$LENGTH(KMPENAM))
+16 SET KMPRET=KMPENAM_"|"_KMPPENAM_"|"_KMPETYP_"|"_KMPRUMD
+17 SET ^KMPVEVT(KMPOPT)=KMPRET
+18 QUIT KMPRET
+19 ;
CALCPKG(KMPENAME) ;
+1 NEW KMPIEN,KMPPKGID,KMPPNAM,KMPPRE,KMPRET
+2 ; CODE FROM SERVER TO SET KMPPKGID
+3 IF $$RESERVED(KMPENAME)
QUIT $$RESPACK(KMPENAME)
+4 SET KMPPKGID=""
SET KMPRET="UNKNOWN^UNKNOWN"
+5 SET KMPPRE=$EXTRACT(KMPENAME,1,4)
Begin DoDot:1
+6 IF $DATA(^DIC(9.4,"C",KMPPRE))
SET KMPPKGID=$ORDER(^DIC(9.4,"C",KMPPRE,""))
End DoDot:1
+7 IF KMPPKGID=""
SET KMPPRE=$EXTRACT(KMPENAME,1,3)
Begin DoDot:1
+8 IF $DATA(^DIC(9.4,"C",KMPPRE))
SET KMPPKGID=$ORDER(^DIC(9.4,"C",KMPPRE,""))
End DoDot:1
+9 IF KMPPKGID=""
SET KMPPRE=$EXTRACT(KMPENAME,1,2)
Begin DoDot:1
+10 IF $DATA(^DIC(9.4,"C",KMPPRE))
SET KMPPKGID=$ORDER(^DIC(9.4,"C",KMPPRE,""))
End DoDot:1
+11 IF KMPPKGID=""
QUIT KMPRET
+12 SET KMPIEN=""
+13 ; IF 2 ENTRIES NO WAY TO DECIDE WHICH IS CORRECT SO TAKE FIRST - DON'T LOOP - RARE OCCURRENCE
+14 SET KMPIEN=$ORDER(^DIC(9.4,"C",KMPPRE,KMPIEN))
if KMPIEN=""
QUIT
Begin DoDot:1
+15 SET KMPPNAM=$PIECE($GET(^DIC(9.4,KMPIEN,0)),"^")
+16 SET KMPRET=KMPPRE_"|"_KMPPNAM
+17 SET ^KMPVPKG(KMPENAME)=KMPRET
End DoDot:1
+18 QUIT KMPRET
+19 ;
RESERVED(KMPENAME) ; Return 1 if system event
+1 IF "#USER#^$AFTR ZTMS$^$STRT ZTMS$^$BROKER HANDLER$^$LOGIN$^$VISTALINK HANDLER$^$XQ MENU DRIVER$^EVE^"[KMPENAME
QUIT 1
+2 IF "#USER#^$AFTR ZTMS$^$STRT ZTMS$^$BROKER HANDLER$^$LOGIN$^$VISTALINK HANDLER$^$XQ MENU DRIVER$"[$EXTRACT(KMPENAME,2,$LENGTH(KMPENAME))
QUIT 1
+3 QUIT 0
+4 ;
RESPACK(KMPENAME) ; Return PREFIX^PACKAGE
+1 IF "^$AFTR ZTMS$^$STRT ZTMS$^$XQ MENU DRIVER$^$LOGIN$^#USER#^EVE^"[KMPENAME
QUIT "XU|KERNEL"
+2 IF "^$BROKER HANDLER$^"[KMPENAME
QUIT "XWB|RPC BROKER"
+3 IF "^$VISTALINK HANDLER$^"[KMPENAME
QUIT "XOBV|VISTALINK"
+4 ; The following code is to fix null vsmpackage in KMPVBusinessEvent 2-14-2018 SCL
+5 IF "^$BROKER HANDLER$^"[$EXTRACT(KMPENAME,2,$LENGTH(KMPENAME))
QUIT "XWB|RPC BROKER"
+6 IF "^$AFTR ZTMS$^$STRT ZTMS$^$XQ MENU DRIVER$^$LOGIN$^#USER#^EVE^"[$EXTRACT(KMPENAME,2,$LENGTH(KMPENAME))
QUIT "XU|KERNEL"
+7 IF "^$VISTALINK HANDLER$^"[$EXTRACT(KMPENAME,2,$LENGTH(KMPENAME))
QUIT "XOBV|VISTALINK"
+8 QUIT ""
+9 ;
SETCFG(KMPCFG) ; Change VSM configuration via national server change request
+1 NEW KMPDATA,KMPEARR,KMPENUM,KMPFNAM,KMPFNUM,KMPFUNC,KMPFVAL,KMPI,KMPIEN,KMPMKEY,KMPMSG,KMPMSG2,KMPON,KMPRESP,KMPRT
+2 NEW KMPRTN,KMPRTO,KMPTEXT,KMPTNUM,KMPVER,FDA
+3 ;
+4 SET KMPFUNC="SETCFG"
+5 SET KMPMKEY=KMPCFG.Monitor
+6 SET (KMPMSG,KMPMSG2)=""
+7 ;
+8 DO STOPMON^KMPVCBG(KMPMKEY,1,1)
+9 ;
+10 SET KMPVER=$$GETVAL^KMPVCCFG(KMPMKEY,"VERSION",8969)
+11 IF KMPCFG.Function'="SetConfig"
QUIT "Incorrect Function Type"
+12 SET KMPFVAL("ALLOW TEST SYSTEM")=KMPCFG.AllowTestSystem
+13 SET KMPFVAL("APIKEY")=KMPCFG.ApiKey
+14 SET KMPFVAL("COLLECTION INTERVAL")=KMPCFG.CollectionInterval
+15 SET KMPFVAL("DAYS TO KEEP DATA")=KMPCFG.DaysToKeepData
+16 SET KMPFVAL("ENCRYPT")=KMPCFG.Encrypt
+17 SET KMPFVAL("HTTP REQUEST MAX LENGTH")=KMPCFG.HttpRequestMaxLength
+18 SET KMPFVAL("MONITOR START DELAY")=KMPCFG.MonitorStartDelay
+19 SET KMPFVAL("NATIONAL DATA EMAIL ADDRESS")=KMPCFG.NationalDataEmailAddress
+20 SET KMPFVAL("NATIONAL FQDN")=KMPCFG.NationalFqdn
+21 SET KMPFVAL("NATIONAL IP ADDRESS")=KMPCFG.NationalIpAddress
+22 SET KMPFVAL("NATIONAL PORT")=KMPCFG.NationalPort
+23 SET KMPFVAL("NATIONAL SUPPORT EMAIL ADDRESS")=KMPCFG.NationalSupportEmailAddress
+24 SET KMPFVAL("ONOFF")=KMPCFG.OnOff
+25 SET KMPFVAL("TASKMAN OPTION")=KMPCFG.TaskmanOption
+26 SET KMPFVAL("VSM CFG EMAIL ADDRESS")=KMPCFG.VsmCfgEmailAddress
+27 ;
+28 ; verify Monitor Type is valid
+29 IF $DATA(^KMPV(8969,"B",KMPMKEY))
SET KMPIEN=$ORDER(^KMPV(8969,"B",KMPMKEY,""))
+30 IF $GET(KMPIEN)=""
QUIT "Monitor "_KMPMKEY_" not defined. No changes made."
+31 ; get field numbers and set FDA array
+32 SET KMPFNAM=""
+33 FOR
SET KMPFNAM=$ORDER(KMPFVAL(KMPFNAM))
if KMPFNAM=""
QUIT
Begin DoDot:1
+34 SET KMPFNUM=$$FLDNUM^DILFD(8969,KMPFNAM)
+35 IF KMPFNUM>0
SET FDA($JOB,8969,KMPIEN_",",KMPFNUM)=KMPFVAL(KMPFNAM)
+36 IF '$TEST
SET KMPEARR(KMPFNAM)=""
End DoDot:1
+37 ;
+38 ; If field name does not exist send message and quit
+39 IF $DATA(KMPEARR)
Begin DoDot:1
+40 SET KMPTEXT("SUBJECT")="VSM ALERT: Configuration Update field(s) do not exist in the VSM CONFIGURATION file "
+41 SET KMPI=1
+42 SET KMPFNAM=""
SET KMPTEXT(KMPI)=KMPMKEY_" Missing Fields"
SET KMPI=KMPI+1
+43 FOR
SET KMPFNAM=$ORDER(KMPEARR(KMPFNAM))
if KMPFNAM=""
QUIT
Begin DoDot:2
+44 SET KMPTEXT(KMPI)=KMPFNAM
SET KMPI=KMPI+1
End DoDot:2
End DoDot:1
QUIT "Configuration Update field(s) do not exist in the VSM CONFIGURATION file"
+45 ;
+46 ; If still good get old values for logging changes
+47 SET KMPFNAM=""
+48 FOR
SET KMPFNAM=$ORDER(KMPFVAL(KMPFNAM))
if KMPFNAM=""
QUIT
Begin DoDot:1
+49 SET $PIECE(KMPFVAL(KMPFNAM),"^",2)=$$GETVAL^KMPVCCFG(KMPMKEY,KMPFNAM,8969,"I")
End DoDot:1
+50 ;
+51 ; ATTEMPT TO MAKE CHANGES
+52 KILL KMPEARR
+53 DO FILE^DIE("ET","FDA($J)","KMPEARR")
+54 ; IF ERRORS SEND MESSAGE WITH ERRORS
+55 SET KMPRESP="OK"
+56 SET KMPI=1
+57 ; Add filing errors to support message
IF $DATA(KMPEARR)
Begin DoDot:1
+58 SET KMPRESP="UPDATE FAILED"
+59 SET KMPTEXT("SUBJECT")="VSM ALERT:"_KMPMKEY_" Configuration Update: WITH ERRORS. "
+60 SET KMPTEXT(KMPI)="Changes NOT applied to VSM CONFIGURATION file. "
SET KMPI=KMPI+1
+61 SET KMPTEXT(KMPI)="Number of errors: "_+KMPEARR("DIERR")
SET KMPI=KMPI+1
+62 SET KMPENUM=""
+63 FOR
SET KMPENUM=$ORDER(KMPEARR("DIERR",KMPENUM))
if +KMPENUM=0
QUIT
Begin DoDot:2
+64 SET KMPTNUM=""
+65 FOR
SET KMPTNUM=$ORDER(KMPEARR("DIERR",KMPENUM,"TEXT",KMPTNUM))
if +KMPTNUM=0
QUIT
Begin DoDot:3
+66 SET KMPTEXT(KMPI)=KMPEARR("DIERR",KMPENUM,"TEXT",KMPTNUM)
SET KMPI=KMPI+1
End DoDot:3
End DoDot:2
+67 DO INFOMSG^KMPUTLW(.KMPTEXT)
End DoDot:1
+68 ; If no FILING errors then list changes in Support Message and Log Changes
+69 IF '$DATA(KMPEARR)
Begin DoDot:1
+70 SET KMPI=1
+71 SET KMPTEXT("SUBJECT")="VSM CONFIGURATION: "_KMPMKEY_" Configuration Update: No Errors. "
+72 SET KMPTEXT(KMPI)="Changes applied to VSM CONFIGURATION file. "
SET KMPI=KMPI+1
+73 ; list changes in Support Message
+74 SET KMPFNAM=""
SET KMPTEXT(KMPI)="Changed Fields"
SET KMPI=KMPI+1
+75 FOR
SET KMPFNAM=$ORDER(KMPFVAL(KMPFNAM))
if KMPFNAM=""
QUIT
Begin DoDot:2
+76 SET KMPDATA=KMPFVAL(KMPFNAM)
+77 SET KMPTEXT(KMPI)=KMPFNAM_"-"_$PIECE(KMPDATA,"^",2)_" TO "_$PIECE(KMPDATA,"^")
SET KMPI=KMPI+1
End DoDot:2
+78 DO INFOMSG^KMPUTLW(.KMPTEXT)
End DoDot:1
+79 ; if end state is 'ON' then start monitor
+80 IF $$GETVAL^KMPVCCFG(KMPMKEY,"ONOFF",8969)="ON"
DO STARTMON^KMPVCBG(KMPMKEY,1,1)
+81 ;
+82 QUIT KMPRESP
+83 ;
GETERR(KMPRET,KMPREQ) ; Return run history recorded in the VSM CACHE TASK LOG file
+1 NEW KMPD,KMPDAT,KMPENUM,KMPINODE,KMPJNODE,KMPUVNB,KMPVAL,KMPVAR,KMPVNUM,KMPVOBJ
+2 ;
+3 SET KMPDAT=KMPREQ.ErrorDate
+4 IF KMPDAT=""
SET KMPRET.Status="No Date Provided"
QUIT
+5 SET KMPDAT=$ZDATEH(KMPDAT,3)
+6 SET KMPENUM=KMPREQ.ErrorNumber
+7 IF KMPENUM=""
SET KMPRET.Status="No Error Number Provided"
QUIT
+8 SET KMPD=##class(%DynamicObject).%New()
+9 IF '$DATA(^%ZTER(1,KMPDAT,1,KMPENUM))
SET KMPRET.Status="Error Not Found"
QUIT
+10 SET KMPD.ErrorNumber=+$GET(^%ZTER(1,KMPDAT,1,KMPENUM,0))
+11 SET KMPD.LastGlobalReference=$GET(^%ZTER(1,KMPDAT,1,KMPENUM,"GR"))
+12 SET KMPINODE=$GET(^%ZTER(1,KMPDAT,1,KMPENUM,"I"))
+13 SET KMPD.CurrentIo=$PIECE(KMPINODE,"^",1)
+14 SET KMPD.ZaValue=$PIECE(KMPINODE,"^",2)
+15 SET KMPD.ZbValue=$PIECE(KMPINODE,"^",3)
+16 SET KMPD.CurrentZio=$PIECE(KMPINODE,"^",4)
+17 SET KMPD.HValue=$GET(^%ZTER(1,KMPDAT,1,KMPENUM,"H"))
+18 SET KMPJNODE=$GET(^%ZTER(1,KMPDAT,1,KMPENUM,"J"))
+19 SET KMPD.JobNumber=$PIECE(KMPJNODE,"^",1)
+20 SET KMPD.ProcessName=$PIECE(KMPJNODE,"^",2)
+21 SET KMPD.UserName=$PIECE(KMPJNODE,"^",3)
+22 SET KMPUVNB=$PIECE(KMPJNODE,"^",4)
+23 SET KMPD.Uci=$PIECE(KMPUVNB,"~",1)
+24 SET KMPD.Vol=$PIECE(KMPUVNB,"~",1)
+25 SET KMPD.Node=$PIECE(KMPUVNB,"~",1)
+26 SET KMPD.Box=$PIECE(KMPUVNB,"~",1)
+27 SET KMPD.AlternateJobNumber=$PIECE(KMPJNODE,"^",5)
+28 SET KMPD.Line=$GET(^%ZTER(1,KMPDAT,1,KMPENUM,"LINE"))
+29 SET KMPD.ZE=$GET(^%ZTER(1,KMPDAT,1,KMPENUM,"ZE"))
+30 SET KMPVNUM=0
SET KMPVOBJ=##class(%DynamicObject).%New()
+31 FOR
SET KMPVNUM=$ORDER(^%ZTER(1,KMPDAT,1,KMPENUM,"ZV",KMPVNUM))
if +KMPVNUM=0
QUIT
Begin DoDot:1
+32 SET KMPVAR=^%ZTER(1,KMPDAT,1,KMPENUM,"ZV",KMPVNUM,0)
+33 SET KMPVAL=^%ZTER(1,KMPDAT,1,KMPENUM,"ZV",KMPVNUM,"D")
+34 DO KMPVOBJ.%Set(KMPVAR,KMPVAL)
End DoDot:1
+35 SET KMPD.Variables=KMPVOBJ
+36 SET KMPRET.Status="Error Found"
+37 SET KMPRET.Error=KMPD
+38 QUIT