RORTSK01 ;HCIOFO/SG - (SUB)TASK UTILITIES ; 1/22/06 8:05pm
;;1.5;CLINICAL CASE REGISTRIES;;Feb 17, 2006
;
; These utilities should be called only from the tasks and subtasks
; that are created and scheduled by the RORTSK API.
;
; The RORTSK local array is passed to the task. If the proxy task
; is used then it passes this array by reference into the entry
; point that implements the generic task or report.
;
; RORTSK( Task Number
;
; "PARAMS",...) Report Parameters
; "TPP-PREV") Previous value of task progress percentage
;
; If the proxy task is used, additional nodes are created:
;
; "EP") Entry Point
; "TYPE") Type of the Task
; "REGIEN") Registry IEN
; "REPORT") Code of the Report
; "SCHCODE") Rescheduling Code
;
; See descriptions of the REPORT BUILDER field (10.01) of the
; ROR REPORT PARAMETERS file (#799.34) and the ROR REPORT SCHEDULE
; remote procedure for more details.
;
Q
;
;***** DUMMY ENTRY POINT (TO AVOID CRASH DURING ALERT PROCESSING)
ALERTRTN Q
;
;***** (SUB)TASK CLEANUP
;
; ERRCODE Error code of the task
; [PARENT] Parent task for the subtask
;
; Return Values:
; <0 Error code
; 0 Ok
;
EXIT(ERRCODE,PARENT) ;
N IENS,RC,RORFDA,RORMSG,STATUS,TASKINFO,TASKNODE,TMP
S RC=0,STATUS=$S(ERRCODE=-42:5,ERRCODE<0:101,1:3),ZTREQ="@"
;=== SUBTASK
I $G(PARENT) D Q RC
. ;--- Not implemented
;=== TASK
S TASKNODE=$NA(^RORDATA(798.8,RORTSK))
S TMP=$$TASKINFO^RORTSK02(RORTSK,.TASKINFO)
;--- Report statistics
D:+$G(TASKINFO(2))=2
. S TMP=+$G(TASKINFO(3)) ; Registry IEN
. D:TMP>0 INC^RORTSK12(TMP,+$G(TASKINFO(4)))
;--- Send an alert to the user who has started the task
S TMP=$G(TASKINFO(5)) ; Task Description
D ORALERT^RORUTL18($$MSG^RORERR20(-101,,,RORTSK,TMP))
;--- Update the task record
S IENS=RORTSK_","
S RORFDA(798.8,IENS,2.01)=STATUS ; Status
S RORFDA(798.8,IENS,2.02)=$$NOW^XLFDT ; Completion Time
S RORFDA(798.8,IENS,2.04)="@" ; Job Number
S RORFDA(798.8,IENS,4)="@" ; Progress
D FILE^DIE(,"RORFDA","RORMSG")
S:$G(DIERR) RC=$$DBS^RORERR("RORMSG",-9,,,798.8,IENS)
;--- Cleanup
K @TASKNODE@("A"),@TASKNODE@("T")
L -@TASKNODE@("T",0)
Q RC
;
;***** INITIALIZES THE (SUB)TASK
;
; TASK Task number
; [LOG] Log IEN (returned by the $$LOGIEN^RORLOG function)
; [PARENT] Parent task for the subtask
;
; Return Values:
; <0 Error code
; 0 Ok
;
INIT(TASK,LOG,PARENT) ;
N I,RC,RORDTH,RORFDA,RORMSG,TASKNODE
S RORDTH=$G(ZTDTH) S:RORDTH'>0 RORDTH=$$NOW^XLFDT
S RC=0,RORTSK=+TASK K RORTSK("PREVTPP")
;=== SUBTASK
I $G(PARENT) S RC=0 D Q RC
. ;--- Not implemented
;=== TASK
S TASKNODE=$NA(^RORDATA(798.8,RORTSK))
;--- Schedule the next instance of the task (if requested)
D:$G(RORTSK("SCHCODE"))'=""
. N EP,TYPE,REGIEN,REPORT,SCHCODE
. N ZTCPU,ZTDTH,ZTIO,ZTKIL,ZTPRI,ZTSAVE,ZTSYNC,ZTUCI
. F I="EP","TYPE","REGIEN","REPORT","SCHCODE" S @I=$G(RORTSK(I))
. Q:(TYPE'>0)!(EP="")
. S ZTDTH=$$SCH^XLFDT(SCHCODE,RORDTH,1)
. S TMP=$$CREATE^RORTSK(TYPE,EP,,REGIEN,REPORT,SCHCODE,.RORTSK)
;--- Wait until the task record is created
S RC=$$TRWAIT(RORTSK) Q:RC<0 RC
;--- Lock the task record
L +@TASKNODE@("T",0):5
E Q $$ERROR^RORERR(-11,,,,"the ROR TASK file")
;--- Clear the list of subtasks
K @TASKNODE@("T")
;--- Update the task record
S IENS=RORTSK_","
S RORFDA(798.8,IENS,2.01)=100 ; STATUS = 'Crashed'
S RORFDA(798.8,IENS,2.03)=$G(LOG) ; Log IEN
S RORFDA(798.8,IENS,2.04)=$J ; Job Number
D FILE^DIE(,"RORFDA","RORMSG")
S:$G(DIERR) RC=$$DBS^RORERR("RORMSG",-9,,,798.8,IENS)
Q RC
;
;***** TASK CONTROL FUNCTION
;
; [TPP] Task/Section progress (0-1)
;
; Return Values:
; <0 Error code
; 0 Ok
;
LOOP(TPP) ;
N ACTION,OFFSET,RC
;--- Update the task progress percentage
D:$G(TPP)'=""
. I TPP'<0,TPP'>1 D S TPP=+$J(TPP,0,2)
. . S TPP=TPP*$G(RORTSK("TPP-BASE"),100)+$G(RORTSK("TPP-OFFS"))
. E S TPP=""
. Q:TPP=$G(RORTSK("TPP-PREV"))
. S (^RORDATA(798.8,RORTSK,"P"),RORTSK("TPP-PREV"))=TPP
;--- Requested action
S ACTION=$S($$S^%ZTLOAD:2,1:+$G(^RORDATA(798.8,RORTSK,"A")))
Q:'ACTION 0
;=== SUSPEND THE TASK
I ACTION=1 S RC=0 D Q RC
. N IENS,RORFDA,RORMSG
. S IENS=RORTSK_","
. ;--- Update the task status
. S RORFDA(798.8,IENS,2.01)=102 ; STATUS = 'Suspended'
. D FILE^DIE(,"RORFDA","RORMSG")
. S:$G(DIERR) RC=$$DBS^RORERR("RORMSG",-9,,,798.8,IENS)
. ;--- Suspension cycle
. F H 60 D Q:ACTION'=1
. . S ACTION=$S($$S^%ZTLOAD:2,1:+$G(^RORDATA(798.8,RORTSK,"A")))
. ;--- Restore the default task status
. S RORFDA(798.8,IENS,2.01)=100 ; STATUS = 'Crashed'
. D FILE^DIE(,"RORFDA","RORMSG")
. S:$G(DIERR) RC=$$DBS^RORERR("RORMSG",-9,,,798.8,IENS)
;=== STOP THE TASK
I ACTION=2 D Q $$ERROR^RORERR(-42)
. S ZTSTOP=1
Q 0
;
;***** RETURNS THE VALUE/ATTRIBUTE OF THE TASK PARAMETER
PARAM(NAME,ATTR) ;
Q:$G(ATTR)'="" $G(RORTSK("PARAMS",NAME,"A",ATTR))
Q $G(RORTSK("PARAMS",NAME))
;
;***** TASK PROXY
;
; RORTSK("EP") This node must contain name of the task entry point
; ($$TAG^ROUTINE). The function should return either
; a negative error code or zero.
;
TASK ;
N RORCACHE ; Cache of element and attribute names
N RORLOG ; Log subsystem constants & variables
N RORPARM ; Application parameters
;
N ACTIVITY,I,INFO,RC,REGLST,RORERRDL,TASKINFO,TMP,TRC
S RORTSK=ZTSK
;--- Initialize constants and variables
D INIT^RORUTL01("ROR")
;S RORPARM("DEBUG")=1 ; Remove the first ';' to start in debug mode
S RORPARM("ERR")=1 ; Enable enhanced error processing
S RORPARM("LOG")=1 ; Enable error recording
;--- Wait until the task record is created
S TMP=$$TRWAIT(RORTSK)
;--- Get the task information
S TRC=$$TASKINFO^RORTSK02(RORTSK,.TASKINFO,"E")
;--- Open a task log
S TMP=$P($G(TASKINFO(3)),U,2) S:TMP'="" REGLST(TMP)=""
S ACTIVITY=$S(+$G(TASKINFO(2))=2:5,1:0)
S TMP=$$SETUP^RORLOG(.REGLST)
S RC=$$OPEN^RORLOG(.REGLST,ACTIVITY,"TASK #"_RORTSK_" STARTED")
;--- Abort the task if task information was not available
I TRC<0 D:RC'<0 Q
. S TMP=$$ERROR^RORERR(-56,,,,TRC,"$$TASKINFO^RORTSK02")
. D CLOSE^RORLOG("TASK #"_RORTSK_" ABORTED")
D
. ;--- Record the task information (if available)
. S I=0,TMP=$G(TASKINFO(5))
. S:TMP'="" I=I+1,INFO(I)="Description: '"_TMP_"'"
. S TMP=$P($G(TASKINFO(8)),U,2)
. S:TMP'="" I=I+1,INFO(I)="User: '"_TMP_"'"
. S TMP=$G(TASKINFO(14))
. S:TMP'="" I=I+1,INFO(I)="Comment: '"_TMP_"'"
. D:I LOG^RORLOG(2,"Task Information",,.INFO)
. ;--- Verify the entry point
. S RC=$$VERIFYEP^RORUTL01($G(RORTSK("EP")),1) Q:RC<0
. ;--- Initialize the task
. S RC=$$INIT(RORTSK,$$LOGIEN^RORLOG) Q:RC<0
. K ACTIVITY,INFO,REGLST,TASKINFO,TMP
. ;--- Call the entry point
. X "S TRC="_RORTSK("EP")_"(.RORTSK)"
;
;--- Post-processing
S TMP=$$EXIT(TRC)
;--- Close the log
S TMP="TASK #"_RORTSK_$S(TRC<0:" ABORTED",1:" COMPLETED")
D CLOSE^RORLOG(TMP)
Q
;
;***** SETS THE BASE VALUE FOR THE PROGRESS INDICATOR
;
; BASE Base value for the progress indicator (0-100)
;
TPPSETUP(BASE) ;
I $G(BASE)'>0 K RORTSK("TPP-BASE"),RORTSK("TPP-OFFS") Q
N TMP
S RORTSK("TPP-OFFS")=$G(RORTSK("TPP-OFFS"))+$G(RORTSK("TPP-BASE"))
S TMP=100-$G(RORTSK("TPP-OFFS"))
S RORTSK("TPP-BASE")=$S(BASE<TMP:BASE,1:TMP)
S TMP=$$LOOP(0)
Q
;
;***** WAITS UNTIL THE TASK RECORD IS CREATED
;
; TASK Task number
;
; Return Values:
; <0 Error code
; 0 Ok
;
TRWAIT(TASK) ;
N I F I=1:1:5 Q:$D(^RORDATA(798.8,TASK,0)) H 1
Q $S($D(^RORDATA(798.8,TASK,0)):0,1:$$ERROR^RORERR(-83,,,,TASK))
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HRORTSK01 7969 printed Dec 13, 2024@01:43:29 Page 2
RORTSK01 ;HCIOFO/SG - (SUB)TASK UTILITIES ; 1/22/06 8:05pm
+1 ;;1.5;CLINICAL CASE REGISTRIES;;Feb 17, 2006
+2 ;
+3 ; These utilities should be called only from the tasks and subtasks
+4 ; that are created and scheduled by the RORTSK API.
+5 ;
+6 ; The RORTSK local array is passed to the task. If the proxy task
+7 ; is used then it passes this array by reference into the entry
+8 ; point that implements the generic task or report.
+9 ;
+10 ; RORTSK( Task Number
+11 ;
+12 ; "PARAMS",...) Report Parameters
+13 ; "TPP-PREV") Previous value of task progress percentage
+14 ;
+15 ; If the proxy task is used, additional nodes are created:
+16 ;
+17 ; "EP") Entry Point
+18 ; "TYPE") Type of the Task
+19 ; "REGIEN") Registry IEN
+20 ; "REPORT") Code of the Report
+21 ; "SCHCODE") Rescheduling Code
+22 ;
+23 ; See descriptions of the REPORT BUILDER field (10.01) of the
+24 ; ROR REPORT PARAMETERS file (#799.34) and the ROR REPORT SCHEDULE
+25 ; remote procedure for more details.
+26 ;
+27 QUIT
+28 ;
+29 ;***** DUMMY ENTRY POINT (TO AVOID CRASH DURING ALERT PROCESSING)
ALERTRTN QUIT
+1 ;
+2 ;***** (SUB)TASK CLEANUP
+3 ;
+4 ; ERRCODE Error code of the task
+5 ; [PARENT] Parent task for the subtask
+6 ;
+7 ; Return Values:
+8 ; <0 Error code
+9 ; 0 Ok
+10 ;
EXIT(ERRCODE,PARENT) ;
+1 NEW IENS,RC,RORFDA,RORMSG,STATUS,TASKINFO,TASKNODE,TMP
+2 SET RC=0
SET STATUS=$SELECT(ERRCODE=-42:5,ERRCODE<0:101,1:3)
SET ZTREQ="@"
+3 ;=== SUBTASK
+4 IF $GET(PARENT)
Begin DoDot:1
+5 ;--- Not implemented
End DoDot:1
QUIT RC
+6 ;=== TASK
+7 SET TASKNODE=$NAME(^RORDATA(798.8,RORTSK))
+8 SET TMP=$$TASKINFO^RORTSK02(RORTSK,.TASKINFO)
+9 ;--- Report statistics
+10 if +$GET(TASKINFO(2))=2
Begin DoDot:1
+11 ; Registry IEN
SET TMP=+$GET(TASKINFO(3))
+12 if TMP>0
DO INC^RORTSK12(TMP,+$GET(TASKINFO(4)))
End DoDot:1
+13 ;--- Send an alert to the user who has started the task
+14 ; Task Description
SET TMP=$GET(TASKINFO(5))
+15 DO ORALERT^RORUTL18($$MSG^RORERR20(-101,,,RORTSK,TMP))
+16 ;--- Update the task record
+17 SET IENS=RORTSK_","
+18 ; Status
SET RORFDA(798.8,IENS,2.01)=STATUS
+19 ; Completion Time
SET RORFDA(798.8,IENS,2.02)=$$NOW^XLFDT
+20 ; Job Number
SET RORFDA(798.8,IENS,2.04)="@"
+21 ; Progress
SET RORFDA(798.8,IENS,4)="@"
+22 DO FILE^DIE(,"RORFDA","RORMSG")
+23 if $GET(DIERR)
SET RC=$$DBS^RORERR("RORMSG",-9,,,798.8,IENS)
+24 ;--- Cleanup
+25 KILL @TASKNODE@("A"),@TASKNODE@("T")
+26 LOCK -@TASKNODE@("T",0)
+27 QUIT RC
+28 ;
+29 ;***** INITIALIZES THE (SUB)TASK
+30 ;
+31 ; TASK Task number
+32 ; [LOG] Log IEN (returned by the $$LOGIEN^RORLOG function)
+33 ; [PARENT] Parent task for the subtask
+34 ;
+35 ; Return Values:
+36 ; <0 Error code
+37 ; 0 Ok
+38 ;
INIT(TASK,LOG,PARENT) ;
+1 NEW I,RC,RORDTH,RORFDA,RORMSG,TASKNODE
+2 SET RORDTH=$GET(ZTDTH)
if RORDTH'>0
SET RORDTH=$$NOW^XLFDT
+3 SET RC=0
SET RORTSK=+TASK
KILL RORTSK("PREVTPP")
+4 ;=== SUBTASK
+5 IF $GET(PARENT)
SET RC=0
Begin DoDot:1
+6 ;--- Not implemented
End DoDot:1
QUIT RC
+7 ;=== TASK
+8 SET TASKNODE=$NAME(^RORDATA(798.8,RORTSK))
+9 ;--- Schedule the next instance of the task (if requested)
+10 if $GET(RORTSK("SCHCODE"))'=""
Begin DoDot:1
+11 NEW EP,TYPE,REGIEN,REPORT,SCHCODE
+12 NEW ZTCPU,ZTDTH,ZTIO,ZTKIL,ZTPRI,ZTSAVE,ZTSYNC,ZTUCI
+13 FOR I="EP","TYPE","REGIEN","REPORT","SCHCODE"
SET @I=$GET(RORTSK(I))
+14 if (TYPE'>0)!(EP="")
QUIT
+15 SET ZTDTH=$$SCH^XLFDT(SCHCODE,RORDTH,1)
+16 SET TMP=$$CREATE^RORTSK(TYPE,EP,,REGIEN,REPORT,SCHCODE,.RORTSK)
End DoDot:1
+17 ;--- Wait until the task record is created
+18 SET RC=$$TRWAIT(RORTSK)
if RC<0
QUIT RC
+19 ;--- Lock the task record
+20 LOCK +@TASKNODE@("T",0):5
+21 IF '$TEST
QUIT $$ERROR^RORERR(-11,,,,"the ROR TASK file")
+22 ;--- Clear the list of subtasks
+23 KILL @TASKNODE@("T")
+24 ;--- Update the task record
+25 SET IENS=RORTSK_","
+26 ; STATUS = 'Crashed'
SET RORFDA(798.8,IENS,2.01)=100
+27 ; Log IEN
SET RORFDA(798.8,IENS,2.03)=$GET(LOG)
+28 ; Job Number
SET RORFDA(798.8,IENS,2.04)=$JOB
+29 DO FILE^DIE(,"RORFDA","RORMSG")
+30 if $GET(DIERR)
SET RC=$$DBS^RORERR("RORMSG",-9,,,798.8,IENS)
+31 QUIT RC
+32 ;
+33 ;***** TASK CONTROL FUNCTION
+34 ;
+35 ; [TPP] Task/Section progress (0-1)
+36 ;
+37 ; Return Values:
+38 ; <0 Error code
+39 ; 0 Ok
+40 ;
LOOP(TPP) ;
+1 NEW ACTION,OFFSET,RC
+2 ;--- Update the task progress percentage
+3 if $GET(TPP)'=""
Begin DoDot:1
+4 IF TPP'<0
IF TPP'>1
Begin DoDot:2
+5 SET TPP=TPP*$GET(RORTSK("TPP-BASE"),100)+$GET(RORTSK("TPP-OFFS"))
End DoDot:2
SET TPP=+$JUSTIFY(TPP,0,2)
+6 IF '$TEST
SET TPP=""
+7 if TPP=$GET(RORTSK("TPP-PREV"))
QUIT
+8 SET (^RORDATA(798.8,RORTSK,"P"),RORTSK("TPP-PREV"))=TPP
End DoDot:1
+9 ;--- Requested action
+10 SET ACTION=$SELECT($$S^%ZTLOAD:2,1:+$GET(^RORDATA(798.8,RORTSK,"A")))
+11 if 'ACTION
QUIT 0
+12 ;=== SUSPEND THE TASK
+13 IF ACTION=1
SET RC=0
Begin DoDot:1
+14 NEW IENS,RORFDA,RORMSG
+15 SET IENS=RORTSK_","
+16 ;--- Update the task status
+17 ; STATUS = 'Suspended'
SET RORFDA(798.8,IENS,2.01)=102
+18 DO FILE^DIE(,"RORFDA","RORMSG")
+19 if $GET(DIERR)
SET RC=$$DBS^RORERR("RORMSG",-9,,,798.8,IENS)
+20 ;--- Suspension cycle
+21 FOR
HANG 60
Begin DoDot:2
+22 SET ACTION=$SELECT($$S^%ZTLOAD:2,1:+$GET(^RORDATA(798.8,RORTSK,"A")))
End DoDot:2
if ACTION'=1
QUIT
+23 ;--- Restore the default task status
+24 ; STATUS = 'Crashed'
SET RORFDA(798.8,IENS,2.01)=100
+25 DO FILE^DIE(,"RORFDA","RORMSG")
+26 if $GET(DIERR)
SET RC=$$DBS^RORERR("RORMSG",-9,,,798.8,IENS)
End DoDot:1
QUIT RC
+27 ;=== STOP THE TASK
+28 IF ACTION=2
Begin DoDot:1
+29 SET ZTSTOP=1
End DoDot:1
QUIT $$ERROR^RORERR(-42)
+30 QUIT 0
+31 ;
+32 ;***** RETURNS THE VALUE/ATTRIBUTE OF THE TASK PARAMETER
PARAM(NAME,ATTR) ;
+1 if $GET(ATTR)'=""
QUIT $GET(RORTSK("PARAMS",NAME,"A",ATTR))
+2 QUIT $GET(RORTSK("PARAMS",NAME))
+3 ;
+4 ;***** TASK PROXY
+5 ;
+6 ; RORTSK("EP") This node must contain name of the task entry point
+7 ; ($$TAG^ROUTINE). The function should return either
+8 ; a negative error code or zero.
+9 ;
TASK ;
+1 ; Cache of element and attribute names
NEW RORCACHE
+2 ; Log subsystem constants & variables
NEW RORLOG
+3 ; Application parameters
NEW RORPARM
+4 ;
+5 NEW ACTIVITY,I,INFO,RC,REGLST,RORERRDL,TASKINFO,TMP,TRC
+6 SET RORTSK=ZTSK
+7 ;--- Initialize constants and variables
+8 DO INIT^RORUTL01("ROR")
+9 ;S RORPARM("DEBUG")=1 ; Remove the first ';' to start in debug mode
+10 ; Enable enhanced error processing
SET RORPARM("ERR")=1
+11 ; Enable error recording
SET RORPARM("LOG")=1
+12 ;--- Wait until the task record is created
+13 SET TMP=$$TRWAIT(RORTSK)
+14 ;--- Get the task information
+15 SET TRC=$$TASKINFO^RORTSK02(RORTSK,.TASKINFO,"E")
+16 ;--- Open a task log
+17 SET TMP=$PIECE($GET(TASKINFO(3)),U,2)
if TMP'=""
SET REGLST(TMP)=""
+18 SET ACTIVITY=$SELECT(+$GET(TASKINFO(2))=2:5,1:0)
+19 SET TMP=$$SETUP^RORLOG(.REGLST)
+20 SET RC=$$OPEN^RORLOG(.REGLST,ACTIVITY,"TASK #"_RORTSK_" STARTED")
+21 ;--- Abort the task if task information was not available
+22 IF TRC<0
if RC'<0
Begin DoDot:1
+23 SET TMP=$$ERROR^RORERR(-56,,,,TRC,"$$TASKINFO^RORTSK02")
+24 DO CLOSE^RORLOG("TASK #"_RORTSK_" ABORTED")
End DoDot:1
QUIT
+25 Begin DoDot:1
+26 ;--- Record the task information (if available)
+27 SET I=0
SET TMP=$GET(TASKINFO(5))
+28 if TMP'=""
SET I=I+1
SET INFO(I)="Description: '"_TMP_"'"
+29 SET TMP=$PIECE($GET(TASKINFO(8)),U,2)
+30 if TMP'=""
SET I=I+1
SET INFO(I)="User: '"_TMP_"'"
+31 SET TMP=$GET(TASKINFO(14))
+32 if TMP'=""
SET I=I+1
SET INFO(I)="Comment: '"_TMP_"'"
+33 if I
DO LOG^RORLOG(2,"Task Information",,.INFO)
+34 ;--- Verify the entry point
+35 SET RC=$$VERIFYEP^RORUTL01($GET(RORTSK("EP")),1)
if RC<0
QUIT
+36 ;--- Initialize the task
+37 SET RC=$$INIT(RORTSK,$$LOGIEN^RORLOG)
if RC<0
QUIT
+38 KILL ACTIVITY,INFO,REGLST,TASKINFO,TMP
+39 ;--- Call the entry point
+40 XECUTE "S TRC="_RORTSK("EP")_"(.RORTSK)"
End DoDot:1
+41 ;
+42 ;--- Post-processing
+43 SET TMP=$$EXIT(TRC)
+44 ;--- Close the log
+45 SET TMP="TASK #"_RORTSK_$SELECT(TRC<0:" ABORTED",1:" COMPLETED")
+46 DO CLOSE^RORLOG(TMP)
+47 QUIT
+48 ;
+49 ;***** SETS THE BASE VALUE FOR THE PROGRESS INDICATOR
+50 ;
+51 ; BASE Base value for the progress indicator (0-100)
+52 ;
TPPSETUP(BASE) ;
+1 IF $GET(BASE)'>0
KILL RORTSK("TPP-BASE"),RORTSK("TPP-OFFS")
QUIT
+2 NEW TMP
+3 SET RORTSK("TPP-OFFS")=$GET(RORTSK("TPP-OFFS"))+$GET(RORTSK("TPP-BASE"))
+4 SET TMP=100-$GET(RORTSK("TPP-OFFS"))
+5 SET RORTSK("TPP-BASE")=$SELECT(BASE<TMP:BASE,1:TMP)
+6 SET TMP=$$LOOP(0)
+7 QUIT
+8 ;
+9 ;***** WAITS UNTIL THE TASK RECORD IS CREATED
+10 ;
+11 ; TASK Task number
+12 ;
+13 ; Return Values:
+14 ; <0 Error code
+15 ; 0 Ok
+16 ;
TRWAIT(TASK) ;
+1 NEW I
FOR I=1:1:5
if $DATA(^RORDATA(798.8,TASK,0))
QUIT
HANG 1
+2 QUIT $SELECT($DATA(^RORDATA(798.8,TASK,0)):0,1:$$ERROR^RORERR(-83,,,,TASK))