%ZTM4 ;SEA/RDS-TaskMan: Manager, (Waiting List) ;06/19/2000 09:32
;;8.0;KERNEL;**1,118,127,162**;Jul 03, 1995
;
;^%ZTSK(ZTSK) must be locked before call
NQ ;enter a task on the busy device waiting lists
N ZT,ZT1,ZT2,ZT3,ZT4,ZT5,ZTHG,ZTI
K ^%ZTSK(ZTSK,.26) S ZTHG="" ;L +^%ZTSCH("IO")
I ZTIOT'="HG" D I ZTIO(1)="DIRECT" G NQX
. I $D(^%ZTSCH("IO",%ZTIO))[0 S ^(%ZTIO)=ZTIOT
. S ^%ZTSK(ZTSK,.26,%ZTIO)="",^%ZTSCH("IO",%ZTIO,ZTDTH,ZTSK)=""
. I (ZTIO(1)="DIRECT")!('$D(^%ZIS(1,"AHG",ZTIOS))) Q
. S ZT2=""
. F S ZT2=$O(^%ZIS(1,"AHG",ZTIOS,ZT2)) Q:ZT2="" D NAME,ADD
. Q
I ZTIOT="HG" S ZT2=ZTIOS D ADD
I ZTHG]"" S ^%ZTSK(ZTSK,.26)=ZTHG
NQX Q
;
NAME ;NQ--save name of hunt group
S ZTS=$G(^%ZIS(1,ZT2,0))
S ZTN=$P(ZTS,U) I ZTN="" Q
I ZTHG="" S ZTHG=ZTN Q
S ZTHG=ZTHG_","_ZTN
Q
;
ADD ;NQ--add the devices in this hunt group to the list the task waits for
N ZTI,ZT5 S ZT5=""
F S ZT5=$O(^%ZIS(1,ZT2,"HG","B",ZT5)) Q:ZT5="" D
.S ZTI=$P($G(^%ZIS(1,ZT5,0)),U,2) ;Get $I
.I ZTI="" Q
.I $D(^%ZTSCH("IO",ZTI))[0 S ^%ZTSCH("IO",ZTI)=$P($G(^%ZIS(1,ZT5,"TYPE")),"^") ;Get type
.S ^%ZTSCH("IO",ZTI,ZTDTH,ZTSK)="",^%ZTSK(ZTSK,.26,ZTI)=""
Q
;
DQ ;Remove A Task From The Busy Device Waiting Lists, TASK is LOCKED
N ZT,ZT1,ZTL
K ^%ZTSCH("IO",%ZTIO,ZTDTH,ZTSK)
S ZT1=""
F S ZT1=$O(^%ZTSK(ZTSK,.26,ZT1)) Q:ZT1="" K ^%ZTSCH("IO",ZT1,ZTDTH,ZTSK)
K ^%ZTSK(ZTSK,.26) Q
;
KILL ;POST^%ZTMS4, Call To Delete A Task And Unschedule It Completely
;As long as ^%ZTSK(ZTSK) is locked we can remove any reference.
N ZTDTH
I $D(^%ZTSK(ZTSK,0))[0 K ^%ZTSK(ZTSK) Q ;No task to work on.
S ZTDTH=$G(^%ZTSK(ZTSK,.04)) S:ZTDTH="" ZTDTH=$$H3^%ZTM($P(^%ZTSK(ZTSK,0),U,6))
I %ZTIO]"",$D(^%ZTSK(ZTSK,0))#2,$P(^(0),U,6)]"" D DQ
K ^%ZTSK(ZTSK)
N ZT,ZT1,ZT2 D US
Q
;
US ;Un-Schedule a task from all lists
;S ZT1="" F S ZT1=$O(^%ZTSCH("JOB",ZT1)) Q:ZT1="" I $D(^(ZT1,ZTSK)) K ^(ZTSK)
;S ZT1="" F S ZT1=$O(^%ZTSCH(ZT1)) Q:'ZT1 I $D(^(ZT1,ZTSK)) K ^(ZTSK)
K ^%ZTSCH(ZTDTH,ZTSK),^%ZTSCH("JOB",ZTDTH,ZTSK)
S ZT1="" F S ZT1=$O(^%ZTSCH("C",ZT1)) Q:ZT1="" K ^%ZTSCH("C",ZT1,ZTDTH,ZTSK)
;Any others??
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HZTM4 2161 printed Dec 13, 2024@02:16:10 Page 2
%ZTM4 ;SEA/RDS-TaskMan: Manager, (Waiting List) ;06/19/2000 09:32
+1 ;;8.0;KERNEL;**1,118,127,162**;Jul 03, 1995
+2 ;
+3 ;^%ZTSK(ZTSK) must be locked before call
NQ ;enter a task on the busy device waiting lists
+1 NEW ZT,ZT1,ZT2,ZT3,ZT4,ZT5,ZTHG,ZTI
+2 ;L +^%ZTSCH("IO")
KILL ^%ZTSK(ZTSK,.26)
SET ZTHG=""
+3 IF ZTIOT'="HG"
Begin DoDot:1
+4 IF $DATA(^%ZTSCH("IO",%ZTIO))[0
SET ^(%ZTIO)=ZTIOT
+5 SET ^%ZTSK(ZTSK,.26,%ZTIO)=""
SET ^%ZTSCH("IO",%ZTIO,ZTDTH,ZTSK)=""
+6 IF (ZTIO(1)="DIRECT")!('$DATA(^%ZIS(1,"AHG",ZTIOS)))
QUIT
+7 SET ZT2=""
+8 FOR
SET ZT2=$ORDER(^%ZIS(1,"AHG",ZTIOS,ZT2))
if ZT2=""
QUIT
DO NAME
DO ADD
+9 QUIT
End DoDot:1
IF ZTIO(1)="DIRECT"
GOTO NQX
+10 IF ZTIOT="HG"
SET ZT2=ZTIOS
DO ADD
+11 IF ZTHG]""
SET ^%ZTSK(ZTSK,.26)=ZTHG
NQX QUIT
+1 ;
NAME ;NQ--save name of hunt group
+1 SET ZTS=$GET(^%ZIS(1,ZT2,0))
+2 SET ZTN=$PIECE(ZTS,U)
IF ZTN=""
QUIT
+3 IF ZTHG=""
SET ZTHG=ZTN
QUIT
+4 SET ZTHG=ZTHG_","_ZTN
+5 QUIT
+6 ;
ADD ;NQ--add the devices in this hunt group to the list the task waits for
+1 NEW ZTI,ZT5
SET ZT5=""
+2 FOR
SET ZT5=$ORDER(^%ZIS(1,ZT2,"HG","B",ZT5))
if ZT5=""
QUIT
Begin DoDot:1
+3 ;Get $I
SET ZTI=$PIECE($GET(^%ZIS(1,ZT5,0)),U,2)
+4 IF ZTI=""
QUIT
+5 ;Get type
IF $DATA(^%ZTSCH("IO",ZTI))[0
SET ^%ZTSCH("IO",ZTI)=$PIECE($GET(^%ZIS(1,ZT5,"TYPE")),"^")
+6 SET ^%ZTSCH("IO",ZTI,ZTDTH,ZTSK)=""
SET ^%ZTSK(ZTSK,.26,ZTI)=""
End DoDot:1
+7 QUIT
+8 ;
DQ ;Remove A Task From The Busy Device Waiting Lists, TASK is LOCKED
+1 NEW ZT,ZT1,ZTL
+2 KILL ^%ZTSCH("IO",%ZTIO,ZTDTH,ZTSK)
+3 SET ZT1=""
+4 FOR
SET ZT1=$ORDER(^%ZTSK(ZTSK,.26,ZT1))
if ZT1=""
QUIT
KILL ^%ZTSCH("IO",ZT1,ZTDTH,ZTSK)
+5 KILL ^%ZTSK(ZTSK,.26)
QUIT
+6 ;
KILL ;POST^%ZTMS4, Call To Delete A Task And Unschedule It Completely
+1 ;As long as ^%ZTSK(ZTSK) is locked we can remove any reference.
+2 NEW ZTDTH
+3 ;No task to work on.
IF $DATA(^%ZTSK(ZTSK,0))[0
KILL ^%ZTSK(ZTSK)
QUIT
+4 SET ZTDTH=$GET(^%ZTSK(ZTSK,.04))
if ZTDTH=""
SET ZTDTH=$$H3^%ZTM($PIECE(^%ZTSK(ZTSK,0),U,6))
+5 IF %ZTIO]""
IF $DATA(^%ZTSK(ZTSK,0))#2
IF $PIECE(^(0),U,6)]""
DO DQ
+6 KILL ^%ZTSK(ZTSK)
+7 NEW ZT,ZT1,ZT2
DO US
+8 QUIT
+9 ;
US ;Un-Schedule a task from all lists
+1 ;S ZT1="" F S ZT1=$O(^%ZTSCH("JOB",ZT1)) Q:ZT1="" I $D(^(ZT1,ZTSK)) K ^(ZTSK)
+2 ;S ZT1="" F S ZT1=$O(^%ZTSCH(ZT1)) Q:'ZT1 I $D(^(ZT1,ZTSK)) K ^(ZTSK)
+3 KILL ^%ZTSCH(ZTDTH,ZTSK),^%ZTSCH("JOB",ZTDTH,ZTSK)
+4 SET ZT1=""
FOR
SET ZT1=$ORDER(^%ZTSCH("C",ZT1))
if ZT1=""
QUIT
KILL ^%ZTSCH("C",ZT1,ZTDTH,ZTSK)
+5 ;Any others??
+6 QUIT