INHFTM ;DGH,FRW,JSH,JPD; 11 Oct 1999 20:39 ; GIS Formatter background controller
;;3.01;BHL IHS Interfaces with GIS;;JUL 01, 2001
;COPYRIGHT 1991-2000 SAIC
;Background process to scan ^INLHFTSK for entries to process
;
; Input:
; INBPN - Background Process ien
; INHSRVR - Server number
;LOCAL:
; INAVJ - executable code to indicate number of available
; jobs on system, from ^%ZOSF("AVJ")
; INHANG - time to hang after starting a new job,
; from file #4002 field #.05
; INFSHNG - Format Server Hang Time for starting new server
; INHSRVMO - flag for server/non-server processing mode,
; from file #4002 field #2.03
; IN - transaction to process (ien) in ^INLHFTSK
; JOB(1) - executable code to initiate a server
; MODE - maximum number of output jobs,
; from file #4002 field #.1
; DTTM - time transaction should be processed at ($H format)
;
;Intialize local and global variables
S ^INRHB("RUN",INBPN)=$H,^INLHFTSK("COUNT")=0
S INHSRVMO=1,MODE=+$P(^INRHSITE(1,0),U,10),INAVJ=^%ZOSF("AVJ")
S INHANG=$P(^INRHSITE(1,0),U,5) S:'INHANG INHANG=10
S INFSHNG=+$P(^INRHSITE(1,2),U,4)/4 S:INFSHNG>180 INFSHNG=180
S JOB(1)=$$REPLACE^UTIL(^INTHOS(1,1),"*","SRVR^INHFTM(INBPN,INHSRVR)")
D REQUE
F Q:'$$RUN D TMLOOP H 1
;exit here
Q
;
TMLOOP ;Main loop to process transactions
;Lock and unlock to flush cache
D INRHB(INBPN,"Process Transaction")
L +^INRHB("RUN",INBPN):0
L -^INRHB("RUN",INBPN)
S ^INRHB("RUN",INBPN)=$H
;get next transaction
S IN=$$NEXTDA(.PRIO,.DTTM),N=DTTM
;If no transaction Hang otherwise process it
I 'IN D INRHB(INBPN,"Idle") H INHANG Q
E I $$RUN D NEWSRV(JOB(1))
Q
;
NEWSRV(INJCODE) ;Attempt to start a new server
;INPUT:
; INJCODE - Code to initiate new server
;Variables just hanging around
; INBPN - Background process ien (file #4004)
; INAVJ - Code to indicate number of available jobs on system
; MODE - Maximum number of servers
;LOCAL:
; INHSRVR - Server number
;
N Y,INHSRVR,INLK
S INLK=0
F INHSRVR=1:1:MODE L +^INRHB("RUN","SRVR",INBPN,INHSRVR):0 I $T D Q
.S INLK=1
.X INAVJ I Y>1 D
..S ^INRHB("RUN","SRVR",INBPN,INHSRVR)=""
..L -^INRHB("RUN","SRVR",INBPN,INHSRVR)
..X INJCODE I $T H INHANG
.L -^INRHB("RUN","SRVR",INBPN,INHSRVR)
I 'INLK D
.D INRHB(INBPN,"Idle")
.F X=1:1:INFSHNG H 2 Q:'$$RUN
Q
RUN() ;should process continue to run
;OUTPUT:
; function value - 1 => continue, 0 => stop
Q:'$D(^INRHB("RUN",INBPN))!('$G(^INRHSITE(1,"ACT"))) 0
I $D(^%ZOSF("SIGNOFF")) X ^("SIGNOFF") I $T K ^INRHB("RUN") Q 0
Q 1
REQUE ;Look for queue entries that were "in process" at prior shut-down
;**Need to add if task is older than certain time don't reque
N TSK,TIME,PRIO,CNT
S TSK=0,CNT=0 F S TSK=$O(^INLHFTSK(TSK)) Q:'TSK!(CNT>100) D
.S TIME=$P(^INLHFTSK(TSK,0),U,4),PRIO=+$P(^(0),U,6) Q:TIME=""
.S CNT=CNT+1 Q:$D(^INLHFTSK("AH",PRIO,TIME,TSK))
.S ^INLHFTSK("AH",PRIO,TIME,TSK)=""
Q
SRVR(INBPN,INHSRVR) ; Format Controller background process - server
;Main entry point
;INPUT:
; INHSRVR - server number
; INBPN - ien for output controller
;LOCAL:
; DA - transaction to process (ien) in ^INLHFTSK
; INHANG - time to hang after processing a task,
; from file #4002 field #.05
; INHER - error message
; INHMWAIT - maximum time a server should wait for
; something to process before shutting down,
; from file #4002 field #2.04
; INHWAIT - time since a trascation was processed
; MODE - always set to zero (0), used in BACK
;
L +^INRHB("RUN","SRVR",INBPN,INHSRVR):5 E Q
X $G(^INTHOS(1,2))
Q:'$G(INBPN)!'$G(INHSRVR)!'$$RUN
K INHER S X="ERROR^INHFTM",@^%ZOSF("TRAP")
S ^INRHB("RUN","SRVR",INBPN,INHSRVR)=$H
D SETENV^INHUT7
;Start GIS Background process audit if flag is set in Site Parms File
N INPNAME S INPNAME=$P(^INTHPC(INBPN,0),U)
D AUDCHK^XUSAUD D:$D(XUAUDIT) ITIME^XUSAUD(INPNAME,INHSRVR)
X:$$PRIO^INHB1 ^%ZOSF("PRIORITY")
;Set up control variables
S INHANG=$P($G(^INRHSITE(1,0)),U,5) S:'INHANG INHANG=10
S INHMWAIT=$P($G(^INRHSITE(1,2)),U,4) S:'INHMWAIT INHMWAIT=60
S INSHTDN=INHMWAIT*3 S:INSHTDN>3600 INSHTDN=3600 S:INSHTDN<900 INSHTDN=900
S MODE=0,INHWAIT=-INHANG,INSHTDN1=0
F Q:'$$RUN!'$$WAIT D LOOP
HALT ;Halt process
K ^INRHB("RUN","SRVR",INBPN,INHSRVR)
L -^INRHB("RUN","SRVR",INBPN,INHSRVR)
K ^DIJUSV(DUZ)
;Stop background process audit
D:$D(XUAUDIT) AUDSTP^XUSAUD
H
LOOP ;Main loop to process transactions
D INRHB(INBPN,"SRVR, Process Transaction",INHSRVR)
S ^INRHB("RUN","SRVR",INBPN,INHSRVR)=$H
;Update background process audit
D:$D(XUAUDIT) ITIME^XUSAUD(INPNAME,INHSRVR)
L +^INLHFTSK("AH"):3 E H INHANG Q
S DA=$$NEXTDA(.PRIO,.DTTM)
I 'DA D Q
.L -^INLHFTSK("AH")
.D INRHB(INBPN,"Idle",INHSRVR)
.H INHANG
K ^INLHFTSK("AH",PRIO,DTTM,DA)
L -^INLHFTSK("AH")
S INHWAIT=0
D BACK(DA,1)
Q
WAIT() ;max wait time before shutting down
; Return 0 to shut down 1 to not shut down
S INHWAIT=INHWAIT+INHANG,INSHTDN1=INSHTDN1+INSHTDN
Q INHWAIT'>INHMWAIT!(INSHTDN1'>INSHTDN)
NEXTDA(PRIO,DTTM,NOD) ;Get next transaction off queue
;Output: (ref) PRIO - priority
; (ref) DTTM - date,time $H format
; (opt) NOD - node to $Q
;Returns: DA - function value - next transaction to process
;
N DAY,TIME,INCREF K DA
;current date and time, initialize DA="" and NOD=prioriy x-ref
S DAY=+$H,TIME=$P($H,",",2),DA=""
S:$G(NOD)="" NOD="^INLHFTSK(""AH"")"
S NOD=$Q(@NOD)
I NOD'="" D
.;get cross ref., priority, Date and Time
.S INCREF=$QS(NOD,1),PRIO=$QS(NOD,2),DTTM=$QS(NOD,3)
.;set tran time and tran date
.S ND=+DTTM,NT=$P(DTTM,",",2)
.;if PRIO'="",piece 1="AH",transday'>today,(trantime '> now)
.I PRIO'="",INCREF="AH" D
..I (ND=DAY&(NT'>TIME)!(ND<DAY)) S DA=$QS(NOD,4) Q
..S NOD="^INLHFTSK(""AH"","_PRIO_",""99999,99999"")"
..S DA=$$NEXTDA(.PRIO,.DTTM,NOD)
Q +DA
;
ERROR ;Error module for server
S X="HALT^INHFTM",@^%ZOSF("TRAP")
X ^INTHOS(1,3)
S INHER(1)=$S($D(INHER)#2:INHER,1:$$ERRMSG^INHU1)
S INHER(2)="in format controller background server for task "_$G(DA)
;***DA may not be the transaction being processed - it may have been the previous transaction processed
S %="" I +$G(DA) S %=$G(^INLHFTSK(DA,0))
D ENF^INHE($P(%,U,1),$P(%,U,2),$P(%,U,3),"",.INHER)
G HALT
BACK(INTSK,INHSRVMO) ;Background program entry point
N INDTTMZ,INHANG,INHMWAIT,INHWAIT,MODE,BP,SV,INORDUZ,INORDIV
S BP=+$G(INBPN),SV=+$G(INHSRVR)
N INBPN,INHSRVR S INBPN=BP,INHSRVR=SV
S X="ERR^INHF",@^%ZOSF("TRAP") X $G(^INTHOS(1,2)) N INDIPA,INIDA,X,INJ
S U="^" L +^INLHFTSK(INTSK):5 E Q ;***SHOULD REQUE TASK
S X=$P(^INRHSITE(1,0),U,6) X:X ^%ZOSF("PRIORITY")
I '$D(^INLHFTSK(INTSK,0)) D ERROR^INHF("Task deleted from INLHFTSK - "_INTSK) Q
S X=^INLHFTSK(INTSK,0),INTT=+X,INIDA=$P(X,U,2),(DUZ,INORDUZ)=$P(X,U,3),INORDIV=$P(X,U,7),INDTTMZ=$P(X,U,4)
S:$P(X,U,5) DUZ(2)=$P(X,U,5)
D SETDT^UTDT
X $G(^INRHSITE(1,1))
;Load INDIPA array
I $D(^INLHFTSK(INTSK,2))>9 M INDIPA=^INLHFTSK(INTSK,2)
I $D(^INLHFTSK(INTSK,1)) M INIDA=^INLHFTSK(INTSK,1)
L -^INLHFTSK(INTSK)
S I="" F S I=$O(^INRHT("AC",INTT,I)) Q:'I I $D(^INRHT(I)),$P($G(^(I,0)),U,5) S INJ(+$P(^INRHT(I,0),U,7),I)=""
I $D(INJ) D
.S PRIO=.9 F S PRIO=$O(INJ(PRIO)) Q:'PRIO D JL
.S PRIO=0 D JL
Q
JL ;Loop through jobs at priority PRIO
S TRT=0 F S TRT=$O(INJ(PRIO,TRT)) Q:'TRT D
.;Preserve original values of INIDA (INDA) and INA (INDIPA)
.N INA,INDA
.M INA=INDIPA,INDA=INIDA
.K INV,UIF
.S SCR=$P(^INRHT(TRT,0),U,3),DEST=+$P(^INRHT(TRT,0),U,2),INTNAME=$P(^(0),U)
.;Avoid "no program" error if script is missing
.I 'SCR S ER=1,ERROR(1)="No script for transaction type "_$P(^INRHT(TRT,0),U)_" Formatter Task "_$G(INTSK)
.;Start transaction audit
.D:$D(XUAUDIT) TTSTRT^XUSAUD(INTNAME,"",$P(^INTHPC(INBPN,0),U),INHSRVR,"SCRIPT")
.S Z="S ER=$$^IS"_$E(SCR#100000+100000,2,6)_"("_TRT_",.INDA,.INA,"_DEST_","""",$G(INORDUZ,DUZ),$G(INORDIV))"
.; execute script if exists and call INTQRY to link UIF with
.; task number for new DEERS Interface query response. DS
.I SCR X Z I $G(UIF)>0,$G(INTSK)>0 D
.. S:'$L($G(INDTTMZ)) INDTTMZ=$$NOW^%ZTFDT
.. D UPDTUIF^INTQRY(INTSK,INDTTMZ,UIF)
.;Stop transaction audit
.D:$D(XUAUDIT) TTSTP^XUSAUD(0)
.K ^INLHFTSK(INTSK),^INLHFTSK("B",INTT,INTSK)
.Q:'ER
.D ENF^INHE(TRT,.INDA,DUZ,.INA,.ERROR)
Q
INRHB(INBPN,MESS,SRVR,UPDT) ;Update background process file
; Input:
; INBPN-Background process ien
; MESS-Text
; SRVR-Server #
; LAST- 1 Update 3rd piece to $H, 0 leave 3rd piece
S UPDT=$G(UPDT)
I $G(SRVR) S $P(^INRHB("RUN","SRVR",INBPN,SRVR),U,1,2)=$H_U_MESS S:UPDT $P(^(SRVR),U,3)=$H Q
S $P(^INRHB("RUN",INBPN),U,1,2)=$H_U_MESS S:UPDT $P(^(INBPN),U,3)=$H
Q
INHFTM ;DGH,FRW,JSH,JPD; 11 Oct 1999 20:39 ; GIS Formatter background controller
+1 ;;3.01;BHL IHS Interfaces with GIS;;JUL 01, 2001
+2 ;COPYRIGHT 1991-2000 SAIC
+3 ;Background process to scan ^INLHFTSK for entries to process
+4 ;
+5 ; Input:
+6 ; INBPN - Background Process ien
+7 ; INHSRVR - Server number
+8 ;LOCAL:
+9 ; INAVJ - executable code to indicate number of available
+10 ; jobs on system, from ^%ZOSF("AVJ")
+11 ; INHANG - time to hang after starting a new job,
+12 ; from file #4002 field #.05
+13 ; INFSHNG - Format Server Hang Time for starting new server
+14 ; INHSRVMO - flag for server/non-server processing mode,
+15 ; from file #4002 field #2.03
+16 ; IN - transaction to process (ien) in ^INLHFTSK
+17 ; JOB(1) - executable code to initiate a server
+18 ; MODE - maximum number of output jobs,
+19 ; from file #4002 field #.1
+20 ; DTTM - time transaction should be processed at ($H format)
+21 ;
+22 ;Intialize local and global variables
+23 SET ^INRHB("RUN",INBPN)=$HOROLOG
SET ^INLHFTSK("COUNT")=0
+24 SET INHSRVMO=1
SET MODE=+$PIECE(^INRHSITE(1,0),U,10)
SET INAVJ=^%ZOSF("AVJ")
+25 SET INHANG=$PIECE(^INRHSITE(1,0),U,5)
IF 'INHANG
SET INHANG=10
+26 SET INFSHNG=+$PIECE(^INRHSITE(1,2),U,4)/4
IF INFSHNG>180
SET INFSHNG=180
+27 SET JOB(1)=$$REPLACE^UTIL(^INTHOS(1,1),"*","SRVR^INHFTM(INBPN,INHSRVR)")
+28 DO REQUE
+29 FOR
IF '$$RUN
QUIT
DO TMLOOP
HANG 1
+30 ;exit here
+31 QUIT
+32 ;
TMLOOP ;Main loop to process transactions
+1 ;Lock and unlock to flush cache
+2 DO INRHB(INBPN,"Process Transaction")
+3 LOCK +^INRHB("RUN",INBPN):0
+4 LOCK -^INRHB("RUN",INBPN)
+5 SET ^INRHB("RUN",INBPN)=$HOROLOG
+6 ;get next transaction
+7 SET IN=$$NEXTDA(.PRIO,.DTTM)
SET N=DTTM
+8 ;If no transaction Hang otherwise process it
+9 IF 'IN
DO INRHB(INBPN,"Idle")
HANG INHANG
QUIT
+10 IF '$TEST
IF $$RUN
DO NEWSRV(JOB(1))
+11 QUIT
+12 ;
NEWSRV(INJCODE) ;Attempt to start a new server
+1 ;INPUT:
+2 ; INJCODE - Code to initiate new server
+3 ;Variables just hanging around
+4 ; INBPN - Background process ien (file #4004)
+5 ; INAVJ - Code to indicate number of available jobs on system
+6 ; MODE - Maximum number of servers
+7 ;LOCAL:
+8 ; INHSRVR - Server number
+9 ;
+10 NEW Y,INHSRVR,INLK
+11 SET INLK=0
+12 FOR INHSRVR=1:1:MODE
LOCK +^INRHB("RUN","SRVR",INBPN,INHSRVR):0
IF $TEST
Begin DoDot:1
+13 SET INLK=1
+14 XECUTE INAVJ
IF Y>1
Begin DoDot:2
+15 SET ^INRHB("RUN","SRVR",INBPN,INHSRVR)=""
+16 LOCK -^INRHB("RUN","SRVR",INBPN,INHSRVR)
+17 XECUTE INJCODE
IF $TEST
HANG INHANG
End DoDot:2
+18 LOCK -^INRHB("RUN","SRVR",INBPN,INHSRVR)
End DoDot:1
QUIT
+19 IF 'INLK
Begin DoDot:1
+20 DO INRHB(INBPN,"Idle")
+21 FOR X=1:1:INFSHNG
HANG 2
IF '$$RUN
QUIT
End DoDot:1
+22 QUIT
RUN() ;should process continue to run
+1 ;OUTPUT:
+2 ; function value - 1 => continue, 0 => stop
+3 IF '$DATA(^INRHB("RUN",INBPN))!('$GET(^INRHSITE(1,"ACT")))
QUIT 0
+4 IF $DATA(^%ZOSF("SIGNOFF"))
XECUTE ^("SIGNOFF")
IF $TEST
KILL ^INRHB("RUN")
QUIT 0
+5 QUIT 1
REQUE ;Look for queue entries that were "in process" at prior shut-down
+1 ;**Need to add if task is older than certain time don't reque
+2 NEW TSK,TIME,PRIO,CNT
+3 SET TSK=0
SET CNT=0
FOR
SET TSK=$ORDER(^INLHFTSK(TSK))
IF 'TSK!(CNT>100)
QUIT
Begin DoDot:1
+4 SET TIME=$PIECE(^INLHFTSK(TSK,0),U,4)
SET PRIO=+$PIECE(^(0),U,6)
IF TIME=""
QUIT
+5 SET CNT=CNT+1
IF $DATA(^INLHFTSK("AH",PRIO,TIME,TSK))
QUIT
+6 SET ^INLHFTSK("AH",PRIO,TIME,TSK)=""
End DoDot:1
+7 QUIT
SRVR(INBPN,INHSRVR) ; Format Controller background process - server
+1 ;Main entry point
+2 ;INPUT:
+3 ; INHSRVR - server number
+4 ; INBPN - ien for output controller
+5 ;LOCAL:
+6 ; DA - transaction to process (ien) in ^INLHFTSK
+7 ; INHANG - time to hang after processing a task,
+8 ; from file #4002 field #.05
+9 ; INHER - error message
+10 ; INHMWAIT - maximum time a server should wait for
+11 ; something to process before shutting down,
+12 ; from file #4002 field #2.04
+13 ; INHWAIT - time since a trascation was processed
+14 ; MODE - always set to zero (0), used in BACK
+15 ;
+16 LOCK +^INRHB("RUN","SRVR",INBPN,INHSRVR):5
IF '$TEST
QUIT
+17 XECUTE $GET(^INTHOS(1,2))
+18 IF '$GET(INBPN)!'$GET(INHSRVR)!'$$RUN
QUIT
+19 KILL INHER
SET X="ERROR^INHFTM"
SET @^%ZOSF("TRAP")
+20 SET ^INRHB("RUN","SRVR",INBPN,INHSRVR)=$HOROLOG
+21 DO SETENV^INHUT7
+22 ;Start GIS Background process audit if flag is set in Site Parms File
+23 NEW INPNAME
SET INPNAME=$PIECE(^INTHPC(INBPN,0),U)
+24 DO AUDCHK^XUSAUD
IF $DATA(XUAUDIT)
DO ITIME^XUSAUD(INPNAME,INHSRVR)
+25 IF $$PRIO^INHB1
XECUTE ^%ZOSF("PRIORITY")
+26 ;Set up control variables
+27 SET INHANG=$PIECE($GET(^INRHSITE(1,0)),U,5)
IF 'INHANG
SET INHANG=10
+28 SET INHMWAIT=$PIECE($GET(^INRHSITE(1,2)),U,4)
IF 'INHMWAIT
SET INHMWAIT=60
+29 SET INSHTDN=INHMWAIT*3
IF INSHTDN>3600
SET INSHTDN=3600
IF INSHTDN<900
SET INSHTDN=900
+30 SET MODE=0
SET INHWAIT=-INHANG
SET INSHTDN1=0
+31 FOR
IF '$$RUN!'$$WAIT
QUIT
DO LOOP
HALT ;Halt process
+1 KILL ^INRHB("RUN","SRVR",INBPN,INHSRVR)
+2 LOCK -^INRHB("RUN","SRVR",INBPN,INHSRVR)
+3 KILL ^DIJUSV(DUZ)
+4 ;Stop background process audit
+5 IF $DATA(XUAUDIT)
DO AUDSTP^XUSAUD
+6 HANG
LOOP ;Main loop to process transactions
+1 DO INRHB(INBPN,"SRVR, Process Transaction",INHSRVR)
+2 SET ^INRHB("RUN","SRVR",INBPN,INHSRVR)=$HOROLOG
+3 ;Update background process audit
+4 IF $DATA(XUAUDIT)
DO ITIME^XUSAUD(INPNAME,INHSRVR)
+5 LOCK +^INLHFTSK("AH"):3
IF '$TEST
HANG INHANG
QUIT
+6 SET DA=$$NEXTDA(.PRIO,.DTTM)
+7 IF 'DA
Begin DoDot:1
+8 LOCK -^INLHFTSK("AH")
+9 DO INRHB(INBPN,"Idle",INHSRVR)
+10 HANG INHANG
End DoDot:1
QUIT
+11 KILL ^INLHFTSK("AH",PRIO,DTTM,DA)
+12 LOCK -^INLHFTSK("AH")
+13 SET INHWAIT=0
+14 DO BACK(DA,1)
+15 QUIT
WAIT() ;max wait time before shutting down
+1 ; Return 0 to shut down 1 to not shut down
+2 SET INHWAIT=INHWAIT+INHANG
SET INSHTDN1=INSHTDN1+INSHTDN
+3 QUIT INHWAIT'>INHMWAIT!(INSHTDN1'>INSHTDN)
NEXTDA(PRIO,DTTM,NOD) ;Get next transaction off queue
+1 ;Output: (ref) PRIO - priority
+2 ; (ref) DTTM - date,time $H format
+3 ; (opt) NOD - node to $Q
+4 ;Returns: DA - function value - next transaction to process
+5 ;
+6 NEW DAY,TIME,INCREF
KILL DA
+7 ;current date and time, initialize DA="" and NOD=prioriy x-ref
+8 SET DAY=+$HOROLOG
SET TIME=$PIECE($HOROLOG,",",2)
SET DA=""
+9 IF $GET(NOD)=""
SET NOD="^INLHFTSK(""AH"")"
+10 SET NOD=$QUERY(@NOD)
+11 IF NOD'=""
Begin DoDot:1
+12 ;get cross ref., priority, Date and Time
+13 SET INCREF=$QSUBSCRIPT(NOD,1)
SET PRIO=$QSUBSCRIPT(NOD,2)
SET DTTM=$QSUBSCRIPT(NOD,3)
+14 ;set tran time and tran date
+15 SET ND=+DTTM
SET NT=$PIECE(DTTM,",",2)
+16 ;if PRIO'="",piece 1="AH",transday'>today,(trantime '> now)
+17 IF PRIO'=""
IF INCREF="AH"
Begin DoDot:2
+18 IF (ND=DAY&(NT'>TIME)!(ND<DAY))
SET DA=$QSUBSCRIPT(NOD,4)
QUIT
+19 SET NOD="^INLHFTSK(""AH"","_PRIO_",""99999,99999"")"
+20 SET DA=$$NEXTDA(.PRIO,.DTTM,NOD)
End DoDot:2
End DoDot:1
+21 QUIT +DA
+22 ;
ERROR ;Error module for server
+1 SET X="HALT^INHFTM"
SET @^%ZOSF("TRAP")
+2 XECUTE ^INTHOS(1,3)
+3 SET INHER(1)=$SELECT($DATA(INHER)#2:INHER,1:$$ERRMSG^INHU1)
+4 SET INHER(2)="in format controller background server for task "_$GET(DA)
+5 ;***DA may not be the transaction being processed - it may have been the previous transaction processed
+6 SET %=""
IF +$GET(DA)
SET %=$GET(^INLHFTSK(DA,0))
+7 DO ENF^INHE($PIECE(%,U,1),$PIECE(%,U,2),$PIECE(%,U,3),"",.INHER)
+8 GOTO HALT
BACK(INTSK,INHSRVMO) ;Background program entry point
+1 NEW INDTTMZ,INHANG,INHMWAIT,INHWAIT,MODE,BP,SV,INORDUZ,INORDIV
+2 SET BP=+$GET(INBPN)
SET SV=+$GET(INHSRVR)
+3 NEW INBPN,INHSRVR
SET INBPN=BP
SET INHSRVR=SV
+4 SET X="ERR^INHF"
SET @^%ZOSF("TRAP")
XECUTE $GET(^INTHOS(1,2))
NEW INDIPA,INIDA,X,INJ
+5 ;***SHOULD REQUE TASK
SET U="^"
LOCK +^INLHFTSK(INTSK):5
IF '$TEST
QUIT
+6 SET X=$PIECE(^INRHSITE(1,0),U,6)
IF X
XECUTE ^%ZOSF("PRIORITY")
+7 IF '$DATA(^INLHFTSK(INTSK,0))
DO ERROR^INHF("Task deleted from INLHFTSK - "_INTSK)
QUIT
+8 SET X=^INLHFTSK(INTSK,0)
SET INTT=+X
SET INIDA=$PIECE(X,U,2)
SET (DUZ,INORDUZ)=$PIECE(X,U,3)
SET INORDIV=$PIECE(X,U,7)
SET INDTTMZ=$PIECE(X,U,4)
+9 IF $PIECE(X,U,5)
SET DUZ(2)=$PIECE(X,U,5)
+10 DO SETDT^UTDT
+11 XECUTE $GET(^INRHSITE(1,1))
+12 ;Load INDIPA array
+13 IF $DATA(^INLHFTSK(INTSK,2))>9
MERGE INDIPA=^INLHFTSK(INTSK,2)
+14 IF $DATA(^INLHFTSK(INTSK,1))
MERGE INIDA=^INLHFTSK(INTSK,1)
+15 LOCK -^INLHFTSK(INTSK)
+16 SET I=""
FOR
SET I=$ORDER(^INRHT("AC",INTT,I))
IF 'I
QUIT
IF $DATA(^INRHT(I))
IF $PIECE($GET(^(I,0)),U,5)
SET INJ(+$PIECE(^INRHT(I,0),U,7),I)=""
+17 IF $DATA(INJ)
Begin DoDot:1
+18 SET PRIO=.9
FOR
SET PRIO=$ORDER(INJ(PRIO))
IF 'PRIO
QUIT
DO JL
+19 SET PRIO=0
DO JL
End DoDot:1
+20 QUIT
JL ;Loop through jobs at priority PRIO
+1 SET TRT=0
FOR
SET TRT=$ORDER(INJ(PRIO,TRT))
IF 'TRT
QUIT
Begin DoDot:1
+2 ;Preserve original values of INIDA (INDA) and INA (INDIPA)
+3 NEW INA,INDA
+4 MERGE INA=INDIPA,INDA=INIDA
+5 KILL INV,UIF
+6 SET SCR=$PIECE(^INRHT(TRT,0),U,3)
SET DEST=+$PIECE(^INRHT(TRT,0),U,2)
SET INTNAME=$PIECE(^(0),U)
+7 ;Avoid "no program" error if script is missing
+8 IF 'SCR
SET ER=1
SET ERROR(1)="No script for transaction type "_$PIECE(^INRHT(TRT,0),U)_" Formatter Task "_$GET(INTSK)
+9 ;Start transaction audit
+10 IF $DATA(XUAUDIT)
DO TTSTRT^XUSAUD(INTNAME,"",$PIECE(^INTHPC(INBPN,0),U),INHSRVR,"SCRIPT")
+11 SET Z="S ER=$$^IS"_$EXTRACT(SCR#100000+100000,2,6)_"("_TRT_",.INDA,.INA,"_DEST_","""",$G(INORDUZ,DUZ),$G(INORDIV))"
+12 ; execute script if exists and call INTQRY to link UIF with
+13 ; task number for new DEERS Interface query response. DS
+14 IF SCR
XECUTE Z
IF $GET(UIF)>0
IF $GET(INTSK)>0
Begin DoDot:2
+15 IF '$LENGTH($GET(INDTTMZ))
SET INDTTMZ=$$NOW^%ZTFDT
+16 DO UPDTUIF^INTQRY(INTSK,INDTTMZ,UIF)
End DoDot:2
+17 ;Stop transaction audit
+18 IF $DATA(XUAUDIT)
DO TTSTP^XUSAUD(0)
+19 KILL ^INLHFTSK(INTSK),^INLHFTSK("B",INTT,INTSK)
+20 IF 'ER
QUIT
+21 DO ENF^INHE(TRT,.INDA,DUZ,.INA,.ERROR)
End DoDot:1
+22 QUIT
INRHB(INBPN,MESS,SRVR,UPDT) ;Update background process file
+1 ; Input:
+2 ; INBPN-Background process ien
+3 ; MESS-Text
+4 ; SRVR-Server #
+5 ; LAST- 1 Update 3rd piece to $H, 0 leave 3rd piece
+6 SET UPDT=$GET(UPDT)
+7 IF $GET(SRVR)
SET $PIECE(^INRHB("RUN","SRVR",INBPN,SRVR),U,1,2)=$HOROLOG_U_MESS
IF UPDT
SET $PIECE(^(SRVR),U,3)=$HOROLOG
QUIT
+8 SET $PIECE(^INRHB("RUN",INBPN),U,1,2)=$HOROLOG_U_MESS
IF UPDT
SET $PIECE(^(INBPN),U,3)=$HOROLOG
+9 QUIT