Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: HLCSFMN1

HLCSFMN1.m

Go to the documentation of this file.
  1. HLCSFMN1 ;ALB/JRP - UTILITIES FOR FILER MONITOR;18-MAY-95
  1. ;;1.6;HEALTH LEVEL SEVEN;;Oct 13, 1995
  1. GETINFO(FLRTYPE,OUTARR) ;Get filer information
  1. ;INPUT : FLRTYPE - Flag indicating type of filer to get info on
  1. ; IN = Incoming filer (default)
  1. ; OUT = Outgoing filer
  1. ; OUTARR - Array to put filer information into (full global ref)
  1. ;OUTPUT : X - Number of outgoing filers running
  1. ; OUTARR(PtrSubEntry) = TaskNumber ^ Last$H ^ StopFlag ^
  1. ; Printable$H ^ ErrorMessage
  1. ; PtrSubEntry = Pointer to subentry in file 869.3
  1. ; TaskNumber = Task number of filer
  1. ; Last$H = Last known $H (field #.03 of subentry)
  1. ; StopFlag = Whether or not filer has been asked to stop
  1. ; (field #.02 of subentry)
  1. ; Yes - Filer has been asked to stop
  1. ; No - Filer has not been asked to stop
  1. ; Error - Task stopped due to error
  1. ; Printable$H = Last$H in printable format
  1. ; ErrorMessage = Printable error message - only used when
  1. ; task stopped due to error
  1. ;NOTES : OUTARR() will be initialized (KILLed) on entry
  1. ;
  1. ;Check input
  1. Q:($G(OUTARR)="") 0
  1. S FLRTYPE=$G(FLRTYPE)
  1. S:(FLRTYPE'="OUT") FLRTYPE="IN"
  1. ;Declare variables
  1. N PTRSUB,FLRINFO,FLRDH,PRTDH,STOPFLAG,COUNT,ZTSK,TMP
  1. ;Get filer data
  1. K @OUTARR
  1. D GETFLRS^HLCSUTL2(FLRTYPE,OUTARR)
  1. ;Count number of filers
  1. S PTRSUB=""
  1. F COUNT=0:1 S PTRSUB=+$O(@OUTARR@(PTRSUB)) Q:('PTRSUB) D
  1. .;Convert data
  1. .S FLRINFO=@OUTARR@(PTRSUB)
  1. .;Convert stop flag to printable format
  1. .S STOPFLAG=+$P(FLRINFO,"^",3)
  1. .S $P(FLRINFO,"^",3)=$S(STOPFLAG:"Yes",1:"No")
  1. .;Convert $H to printable format
  1. .S FLRDH=$P(FLRINFO,"^",2)
  1. .S PRTDH=""
  1. .S:(FLRDH'="") PRTDH=$$DH4PRT(FLRDH)
  1. .S $P(FLRINFO,"^",4)=PRTDH
  1. .;Get task's status
  1. .K ZTSK
  1. .S ZTSK=+FLRINFO
  1. .D STAT^%ZTLOAD
  1. .;Problem with task
  1. .I (ZTSK(1)'=2) D
  1. ..;Determine error message
  1. ..S TMP=$S(FLRTYPE="OUT":"Outgoing ",1:"Incoming ")
  1. ..;Task no longer defined
  1. ..S:(ZTSK(1)=0) TMP="** "_TMP_"filer is no longer defined **"
  1. ..;Task hasn't started yet
  1. ..S:(ZTSK(1)=1) TMP=TMP_"filer has not started yet"
  1. ..;Task finished
  1. ..S:(ZTSK(1)=3) TMP=TMP_"filer stopped but didn't delete itself"
  1. ..;Task not scheduled
  1. ..S:(ZTSK(1)=4) TMP="** "_TMP_"filer has not been [re]scheduled **"
  1. ..;Task errored out
  1. ..S:(ZTSK(1)=5) TMP="** "_TMP_"filer has stopped due to error **"
  1. ..;Store error message
  1. ..S $P(FLRINFO,"^",5)=TMP
  1. ..;Use 'Error' for stop flag - don't change if filer hasn't started yet
  1. ..S:(ZTSK(1)'=1) $P(FLRINFO,"^",3)="Error"
  1. .;Store converted data
  1. .S @OUTARR@(PTRSUB)=FLRINFO
  1. ;Return info
  1. Q COUNT
  1. DIFFDH(DH1,DH2) ;DETERMINE DIFFERENCES BETWEEN TWO VALUES OF $H
  1. ;INPUT : DH1 - Beginning $H (defaults to current $H)
  1. ; DH2 - Ending $H (defaults to current $H)
  1. ;OUTPUT : Days ^ Time
  1. ; Days = Number of days between DH1 & DH2
  1. ; Time = Rest of time between DH1 & DH2 => HH:MM:SS
  1. ;NOTES : Difference calculated by subtracting DH1 from DH2
  1. ;
  1. ;Check input
  1. S DH1=$G(DH1)
  1. S:(DH1="") DH1=$H
  1. S DH2=$G(DH2)
  1. S:(DH2="") DH2=$H
  1. ;Declare variables
  1. N DAY1,DAY2,DAYDIF,TIME1,TIME2,TIMEDIF,NEGATE,%
  1. ;Break out day & seconds from $H
  1. S DAY1=+$P(DH1,",",1)
  1. S DAY2=+$P(DH2,",",1)
  1. S TIME1=+$P(DH1,",",2)
  1. S TIME2=+$P(DH2,",",2)
  1. ;Make sure DH2 is after DH1
  1. S NEGATE=0
  1. I ((DAY1>DAY2)!((DAY1=DAY2)&(TIME1>TIME2))) D
  1. .;Switch date/time
  1. .S NEGATE=DAY2
  1. .S DAY2=DAY1
  1. .S DAY1=NEGATE
  1. .S NEGATE=TIME2
  1. .S TIME2=TIME1
  1. .S TIME1=NEGATE
  1. .;Negate answer when done
  1. .S NEGATE=1
  1. ;Determine day difference
  1. S DAYDIF=DAY2-DAY1
  1. ;Determine time difference
  1. ;Same day - just subtract time
  1. S:('DAYDIF) TIMEDIF=TIME2-TIME1
  1. ;Different day - special case exists
  1. I (DAYDIF) D
  1. .;Seconds not different by 24 hours
  1. .I (TIME2<TIME1) D Q
  1. ..;Convert one day from difference to seconds
  1. ..S DAYDIF=DAYDIF-1
  1. ..;Add to ending time
  1. ..S TIME2=TIME2+86400
  1. ..;Subtract times
  1. ..S TIMEDIF=TIME2-TIME1
  1. .;Seconds different by 24 hours
  1. .S TIMEDIF=TIME2-TIME1
  1. ;Convert seconds to time
  1. S %=TIMEDIF
  1. D S^%DTC
  1. S %=%_"000000"
  1. S TIMEDIF=$E(%,2,3)_":"_$E(%,4,5)_":"_$E(%,6,7)
  1. ;Negate results (if needed)
  1. I (NEGATE) D
  1. .S DAYDIF=0-DAYDIF
  1. .;Don't negate 00:00:00
  1. .F %=1:1:4 Q:($P(TIMEDIF,":",%))
  1. .S:(%'=4) TIMEDIF="-"_TIMEDIF
  1. Q DAYDIF_"^"_TIMEDIF
  1. DH4PRT(DH) ;CONVERT $H TO PRINTABLE FORMAT
  1. ;INPUT : DH - $H (defaults to current $H)
  1. ;OUTPUT : Printable format of $H => DD-MMM-YY @ HH:MM:SS
  1. ;
  1. ;Check input
  1. S DH=$G(DH)
  1. S:(DH="") DH=$H
  1. ;Declare variables
  1. N %H,Y,X,%,CNVDATE,CNVTIME
  1. ;Convert $H to external format
  1. S %H=DH
  1. D YX^%DTC
  1. ;Convert to print format
  1. S CNVDATE=$P(Y,"@",1)
  1. S %=%_"000000"
  1. S CNVTIME=$E(%,2,3)_":"_$E(%,4,5)_":"_$E(%,6,7)
  1. S Y=$E(X,6,7)_"-"_$P(CNVDATE," ",1)_"-"_$E(X,2,3)_" @ "_CNVTIME
  1. Q Y
  1. GETATTR ;GET SCREEN ATTRIBUTES USED BY MONITOR
  1. ;INPUT : IOST(0) - Terminal type [as set by entry into DHCP]
  1. ;OUTPUT : The following screen attributes will be defined
  1. ; IOINORM - Normal intensity
  1. ; IOINHI - High Intensity (bold)
  1. ; IOUON - Underline on
  1. ; IOUOFF - Underline off
  1. ; IOBON - Blink on
  1. ; IOBOFF - Blink off
  1. ; IORVON - Reverse video on
  1. ; IORVOFF - Reverse video off
  1. ; IOHOME - Move cursor to home
  1. ; IOELEOL - Erase from cursor to end of line
  1. ;
  1. ;NOTES : If IOST(0) is not defined, a call to HOME^%ZIS will be made
  1. ;
  1. ;Check for IOST(0)
  1. D:('$D(IOST(0))) HOME^%ZIS
  1. ;Declare variables
  1. N X
  1. ;Get screen attributes
  1. S X="IOINORM;IOINHI;IOUON;IOUOFF;IOBON;IOBOFF;IORVON;IORVOFF;IOHOME;IOELEOL"
  1. D ENDR^%ZISS
  1. Q