source: FOIAVistA/trunk/r/HEALTH_LEVEL_SEVEN-HL/HLCSFMN1.m@ 1423

Last change on this file since 1423 was 628, checked in by George Lilly, 15 years ago

initial load of FOIAVistA 6/30/08 version

File size: 5.6 KB
Line 
1HLCSFMN1 ;ALB/JRP - UTILITIES FOR FILER MONITOR;18-MAY-95
2 ;;1.6;HEALTH LEVEL SEVEN;;Oct 13, 1995
3GETINFO(FLRTYPE,OUTARR) ;Get filer information
4 ;INPUT : FLRTYPE - Flag indicating type of filer to get info on
5 ; IN = Incoming filer (default)
6 ; OUT = Outgoing filer
7 ; OUTARR - Array to put filer information into (full global ref)
8 ;OUTPUT : X - Number of outgoing filers running
9 ; OUTARR(PtrSubEntry) = TaskNumber ^ Last$H ^ StopFlag ^
10 ; Printable$H ^ ErrorMessage
11 ; PtrSubEntry = Pointer to subentry in file 869.3
12 ; TaskNumber = Task number of filer
13 ; Last$H = Last known $H (field #.03 of subentry)
14 ; StopFlag = Whether or not filer has been asked to stop
15 ; (field #.02 of subentry)
16 ; Yes - Filer has been asked to stop
17 ; No - Filer has not been asked to stop
18 ; Error - Task stopped due to error
19 ; Printable$H = Last$H in printable format
20 ; ErrorMessage = Printable error message - only used when
21 ; task stopped due to error
22 ;NOTES : OUTARR() will be initialized (KILLed) on entry
23 ;
24 ;Check input
25 Q:($G(OUTARR)="") 0
26 S FLRTYPE=$G(FLRTYPE)
27 S:(FLRTYPE'="OUT") FLRTYPE="IN"
28 ;Declare variables
29 N PTRSUB,FLRINFO,FLRDH,PRTDH,STOPFLAG,COUNT,ZTSK,TMP
30 ;Get filer data
31 K @OUTARR
32 D GETFLRS^HLCSUTL2(FLRTYPE,OUTARR)
33 ;Count number of filers
34 S PTRSUB=""
35 F COUNT=0:1 S PTRSUB=+$O(@OUTARR@(PTRSUB)) Q:('PTRSUB) D
36 .;Convert data
37 .S FLRINFO=@OUTARR@(PTRSUB)
38 .;Convert stop flag to printable format
39 .S STOPFLAG=+$P(FLRINFO,"^",3)
40 .S $P(FLRINFO,"^",3)=$S(STOPFLAG:"Yes",1:"No")
41 .;Convert $H to printable format
42 .S FLRDH=$P(FLRINFO,"^",2)
43 .S PRTDH=""
44 .S:(FLRDH'="") PRTDH=$$DH4PRT(FLRDH)
45 .S $P(FLRINFO,"^",4)=PRTDH
46 .;Get task's status
47 .K ZTSK
48 .S ZTSK=+FLRINFO
49 .D STAT^%ZTLOAD
50 .;Problem with task
51 .I (ZTSK(1)'=2) D
52 ..;Determine error message
53 ..S TMP=$S(FLRTYPE="OUT":"Outgoing ",1:"Incoming ")
54 ..;Task no longer defined
55 ..S:(ZTSK(1)=0) TMP="** "_TMP_"filer is no longer defined **"
56 ..;Task hasn't started yet
57 ..S:(ZTSK(1)=1) TMP=TMP_"filer has not started yet"
58 ..;Task finished
59 ..S:(ZTSK(1)=3) TMP=TMP_"filer stopped but didn't delete itself"
60 ..;Task not scheduled
61 ..S:(ZTSK(1)=4) TMP="** "_TMP_"filer has not been [re]scheduled **"
62 ..;Task errored out
63 ..S:(ZTSK(1)=5) TMP="** "_TMP_"filer has stopped due to error **"
64 ..;Store error message
65 ..S $P(FLRINFO,"^",5)=TMP
66 ..;Use 'Error' for stop flag - don't change if filer hasn't started yet
67 ..S:(ZTSK(1)'=1) $P(FLRINFO,"^",3)="Error"
68 .;Store converted data
69 .S @OUTARR@(PTRSUB)=FLRINFO
70 ;Return info
71 Q COUNT
72DIFFDH(DH1,DH2) ;DETERMINE DIFFERENCES BETWEEN TWO VALUES OF $H
73 ;INPUT : DH1 - Beginning $H (defaults to current $H)
74 ; DH2 - Ending $H (defaults to current $H)
75 ;OUTPUT : Days ^ Time
76 ; Days = Number of days between DH1 & DH2
77 ; Time = Rest of time between DH1 & DH2 => HH:MM:SS
78 ;NOTES : Difference calculated by subtracting DH1 from DH2
79 ;
80 ;Check input
81 S DH1=$G(DH1)
82 S:(DH1="") DH1=$H
83 S DH2=$G(DH2)
84 S:(DH2="") DH2=$H
85 ;Declare variables
86 N DAY1,DAY2,DAYDIF,TIME1,TIME2,TIMEDIF,NEGATE,%
87 ;Break out day & seconds from $H
88 S DAY1=+$P(DH1,",",1)
89 S DAY2=+$P(DH2,",",1)
90 S TIME1=+$P(DH1,",",2)
91 S TIME2=+$P(DH2,",",2)
92 ;Make sure DH2 is after DH1
93 S NEGATE=0
94 I ((DAY1>DAY2)!((DAY1=DAY2)&(TIME1>TIME2))) D
95 .;Switch date/time
96 .S NEGATE=DAY2
97 .S DAY2=DAY1
98 .S DAY1=NEGATE
99 .S NEGATE=TIME2
100 .S TIME2=TIME1
101 .S TIME1=NEGATE
102 .;Negate answer when done
103 .S NEGATE=1
104 ;Determine day difference
105 S DAYDIF=DAY2-DAY1
106 ;Determine time difference
107 ;Same day - just subtract time
108 S:('DAYDIF) TIMEDIF=TIME2-TIME1
109 ;Different day - special case exists
110 I (DAYDIF) D
111 .;Seconds not different by 24 hours
112 .I (TIME2<TIME1) D Q
113 ..;Convert one day from difference to seconds
114 ..S DAYDIF=DAYDIF-1
115 ..;Add to ending time
116 ..S TIME2=TIME2+86400
117 ..;Subtract times
118 ..S TIMEDIF=TIME2-TIME1
119 .;Seconds different by 24 hours
120 .S TIMEDIF=TIME2-TIME1
121 ;Convert seconds to time
122 S %=TIMEDIF
123 D S^%DTC
124 S %=%_"000000"
125 S TIMEDIF=$E(%,2,3)_":"_$E(%,4,5)_":"_$E(%,6,7)
126 ;Negate results (if needed)
127 I (NEGATE) D
128 .S DAYDIF=0-DAYDIF
129 .;Don't negate 00:00:00
130 .F %=1:1:4 Q:($P(TIMEDIF,":",%))
131 .S:(%'=4) TIMEDIF="-"_TIMEDIF
132 Q DAYDIF_"^"_TIMEDIF
133DH4PRT(DH) ;CONVERT $H TO PRINTABLE FORMAT
134 ;INPUT : DH - $H (defaults to current $H)
135 ;OUTPUT : Printable format of $H => DD-MMM-YY @ HH:MM:SS
136 ;
137 ;Check input
138 S DH=$G(DH)
139 S:(DH="") DH=$H
140 ;Declare variables
141 N %H,Y,X,%,CNVDATE,CNVTIME
142 ;Convert $H to external format
143 S %H=DH
144 D YX^%DTC
145 ;Convert to print format
146 S CNVDATE=$P(Y,"@",1)
147 S %=%_"000000"
148 S CNVTIME=$E(%,2,3)_":"_$E(%,4,5)_":"_$E(%,6,7)
149 S Y=$E(X,6,7)_"-"_$P(CNVDATE," ",1)_"-"_$E(X,2,3)_" @ "_CNVTIME
150 Q Y
151GETATTR ;GET SCREEN ATTRIBUTES USED BY MONITOR
152 ;INPUT : IOST(0) - Terminal type [as set by entry into DHCP]
153 ;OUTPUT : The following screen attributes will be defined
154 ; IOINORM - Normal intensity
155 ; IOINHI - High Intensity (bold)
156 ; IOUON - Underline on
157 ; IOUOFF - Underline off
158 ; IOBON - Blink on
159 ; IOBOFF - Blink off
160 ; IORVON - Reverse video on
161 ; IORVOFF - Reverse video off
162 ; IOHOME - Move cursor to home
163 ; IOELEOL - Erase from cursor to end of line
164 ;
165 ;NOTES : If IOST(0) is not defined, a call to HOME^%ZIS will be made
166 ;
167 ;Check for IOST(0)
168 D:('$D(IOST(0))) HOME^%ZIS
169 ;Declare variables
170 N X
171 ;Get screen attributes
172 S X="IOINORM;IOINHI;IOUON;IOUOFF;IOBON;IOBOFF;IORVON;IORVOFF;IOHOME;IOELEOL"
173 D ENDR^%ZISS
174 Q
Note: See TracBrowser for help on using the repository browser.