HLCSIN ;ALB/JRP - INCOMING FILER;01-MAY-95 ;03/07/2011
;;1.6;HEALTH LEVEL SEVEN;**2,30,14,19,62,109,115,122,140,145,153,175**;Oct 13, 1995;Build 2
;Per VHA Directive 6402, this routine should not be modified.
;Supported ICR# 10063, for $$PSET^%ZTLOAD API to make task persistent
STARTIN ;Main entry point for incoming background filer
;Create/find entry denoting this filer in the INCOMING FILER TASK
; NUMBER multiple (field #20) of the HL COMMUNICATION SERVER PARAMETER
; file (#869.3)
N HLFLG,HLEXIT,HLPTRFLR
;
; patch HL*1.6*122
;; N HLDUZ,DUZ ; patch HL*1.6*122 TEST v2: DUZ code removed
N HLDUZ
S HLDUZ=+$G(DUZ)
;
;;patch HL*1.6*175 adds the $$PSET^%ZTLOAD api to set filers to persistent
N HLPERS
I $G(ZTQUEUED) D
.S HLPERS=$$PSET^%ZTLOAD(ZTQUEUED)
;
S HLPTRFLR=+$$CRTFLR^HLCSUTL1(ZTSK,"IN")
;Loop through Logical Links and check for incoming messages
S HLEXIT=0
; patch HL*1.6*122 TEST v2: DUZ code removed
; patch HL*1.6*122, set DUZ for application proxy user
;; D PROXY^HLCSTCP4
S HLPTRFLR("$J")=$J
F D Q:HLEXIT
. S HLFLG=0
. D DEFACK(.HLPTRFLR,.HLFLG,.HLEXIT) Q:HLEXIT
. D ACKNOW(.HLPTRFLR,.HLFLG,.HLEXIT) Q:HLEXIT
. Q:HLFLG
. I $$HDIFF^XLFDT($H,$G(HLPTRFLR("LASTDEL")),2)>3600 D Q
. . S HLPTRFLR("LASTDEL")=$H ; maintain queue sizes
. . D DELQUE(.HLPTRFLR,.HLEXIT) ; no more than once an hour.
. ; patch HL*1.6*122
. ; H 5
. H 1
. D CHKUPD(.HLPTRFLR,.HLEXIT) Q:HLEXIT
S ZTSTOP=1 ;Asked to stop
D DELFLR^HLCSUTL1(HLPTRFLR,"IN") ;Delete entry denoting this filer
S ZTREQ="@"
Q
DEFACK(HLPTRFLR,HLFLG,HLEXIT) ; Process TCP links with a deferred response
N HLXX,HLD0,HLPCT
S HLXX=0
F S HLXX=$O(^HLMA("AC","I",HLXX)) Q:'HLXX D Q:HLEXIT
. ; HL*1.6*122, check the in-queue stop flag
. Q:$P($G(^HLCS(870,HLXX,0)),"^",9)
. D CHKUPD(.HLPTRFLR,.HLEXIT) Q:HLEXIT
. ; patch HL*1.6*109: Does another filer have this?
. ; L +^HLMA("AC","I",HLXX):0 Q:'$T
. ; patch HL*1.6*140 - change the lock node, it conflicts with
. ; lock defined in routine, HLCSREP.
. ; L +^HLMA("AC","I",HLXX):2 Q:'$T ; patch HL*1.6*122
. L +^HLMA("IN-FILER","AC","I",HLXX):0 Q:'$T ; patch HL*1.6*122
. S HLD0=0,HLFLG=1
. ; HL*1.6*109 changes in for loop below, and post-quit code placed
. ; on following lines.
. S HLPCT=0 ; Counter whether filer should stop every 100th entry.
.;**109 - insure queue last processed at least 2 seconds ago
. ; patch HL*1.6*140
. ; I ($$HDIFF^XLFDT($H,$G(^XTMP("HL7-AC","I",HLXX)),2)<2) L -^HLMA("AC","I",HLXX) Q
. I ($$HDIFF^XLFDT($H,$G(^XTMP("HL7-AC","I",HLXX)),2)<2) L -^HLMA("IN-FILER","AC","I",HLXX) Q
. F S HLD0=$O(^HLMA("AC","I",HLXX,HLD0)) Q:'HLD0!(HLEXIT) D
.. ; patch HL*1.6*122 start
.. ; patch HL*1.6*122 TEST v2: DUZ code removed
.. ; DUZ comparison/reset for application proxy user
.. ;; D HLDUZ^HLCSTCP4
.. D HLDUZ2^HLCSTCP4
.. ; protect HLDUZ
.. N HLDUZ
.. S HLPCT=HLPCT+1
.. I '(HLPCT#100) D CHKUPD(.HLPTRFLR,.HLEXIT) Q:HLEXIT
.. ; L +^HLMA(HLD0):0 Q:'$T
.. F L +^HLMA(HLD0):30 Q:$T H 1
.. I '$$CHECKAC("I",HLXX,HLD0) L -^HLMA(HLD0) Q ;-> Quit if not a valid AC xref
.. D DEFACK^HLTP3(HLXX,HLD0)
.. D DEQUE^HLCSREP(HLXX,"I",HLD0)
.. L -^HLMA(HLD0)
.. ; patch HL*1.6*145
.. ; increment counter after message has been processed.
.. D LLCNT^HLCSTCP(HLXX,2)
. ; patch HL*1.6*122 end
. ;**109 -add dt/tm stamp to time queue last processed
. S ^XTMP("HL7-AC","I",HLXX)=$H
. ;**109 -unlock the queue
. ; patch HL*1.6*140
. ; L -^HLMA("AC","I",HLXX)
. L -^HLMA("IN-FILER","AC","I",HLXX)
Q
;
CHECKAC(WAY,IEN870,IEN773) ; If AC xref shouldn't exist, kill it...
;
; Check status and if 3 (processed) kill XREF...
I $P($G(^HLMA(+IEN773,"P")),U)=3 D QUIT "" ;->
. D DEQUE^HLCSREP(IEN870,WAY,IEN773)
;
; Add other checks here in the future...
;
Q 1
;
ACKNOW(HLPTRFLR,HLFLG,HLEXIT) ; Process Logical Link's IN-queue for received message
N HLXX,HLD0,HLD1
S HLXX=0
F S HLXX=$O(^HLCS(870,"AISTAT","P",HLXX)) Q:'HLXX D Q:HLEXIT
. ; HL*1.6*122, check the in-queue stop flag
. Q:$P($G(^HLCS(870,HLXX,0)),"^",9)
. D CHKUPD(.HLPTRFLR,.HLEXIT) Q:HLEXIT
. ; HL*1.6*109: Does another filer have this?
. ; L +^HLCS(870,HLXX,"INFILER"):0 Q:'$T
. L +^HLCS(870,HLXX,"INFILER"):2 Q:'$T ; patch HL*1.6*122
. F D CHKUPD(.HLPTRFLR,.HLEXIT) Q:HLEXIT S HLD0=$$DEQUEUE^HLCSQUE(HLXX,"IN") Q:+HLD0<0 D
.. ;
.. ; patch HL*1.6*122 start
.. ; clean variables except Kernel related variables
.. D
... ; protect variables defined in STARTIN^HLCSIN
... N HLFLG,HLEXIT,HLPTRFLR
... N HLDUZ
... ; protect variables defined in ACKNOW^HLCSIN
... N HLXX,HLD0,HLD1
... D KILL^XUSCLEAN
.. ;
.. ; patch HL*1.6*122 TEST v2: DUZ code removed
.. ; DUZ comparison/reset for application proxy user
.. ;; D HLDUZ^HLCSTCP4
.. D HLDUZ2^HLCSTCP4
.. ; protect HLDUZ
.. N HLDUZ
.. ;Make sure message is ready to be received
.. S HLFLG=1
.. S HLD1=$P(HLD0,"^",2)
.. S HLD0=+HLD0 ; At this point, HLD0=HLXX
.. I $P($G(^HLCS(870,HLD0,1,HLD1,0)),"^",3)'="A" D Q
... D MONITOR^HLCSDR2("D",2,HLD0,HLD1,"IN") ;Set status to DONE
.. D RECEIVE^HLMA0(HLD0,HLD1) ;Process received message
.. D MONITOR^HLCSDR2("D",2,HLD0,HLD1,"IN") ;Set status to DONE
. ; patch HL*1.6*122 end
. I HLD0<0,$D(^HLCS(870,"AISTAT","P",HLXX)) D
. . S HLD1=0 ; Make sure there aren't any loose xrefs hanging around.
. . F S HLD1=$O(^HLCS(870,"AISTAT","P",HLXX,HLD1)) Q:'HLD1 D
. . . ;I '$D(^HLCS(870,HLXX,1,HLD1,0)) K ^HLCS(870,"AISTAT","P",HLXX,HLD1)
. . . I $P($G(^HLCS(870,HLXX,1,HLD1,0)),U,2)'="P" K ^HLCS(870,"AISTAT","P",HLXX,HLD1)
. L -^HLCS(870,HLXX,"INFILER")
Q
DELQUE(HLPTRFLR,HLEXIT) ; Delete messages outside the 'queue size' window.
N HLDIR,HLXX,HLFRONT
S HLDIR=1,HLXX=0
F S HLXX=$O(^HLCS(870,HLXX)) Q:'HLXX D Q:HLEXIT
. D CHKUPD(.HLPTRFLR,.HLEXIT) Q:HLEXIT
. ; patch HL*1.6*122, comment out, no need to lock
. ; L +^HLCS(870,HLXX,"IN QUEUE FRONT POINTER"):0 Q:'$T
. S HLFRONT=$G(^HLCS(870,HLXX,"IN QUEUE FRONT POINTER"))
. ; patch HL*1.6*122, comment out
. ; L -^HLCS(870,HLXX,"IN QUEUE FRONT POINTER")
. D DELETE^HLCSQUE1(HLXX,HLDIR,HLFRONT)
Q
CHKUPD(HLPTRFLR,HLEXIT) ;
Q:$$HDIFF^XLFDT($H,$G(HLPTRFLR("LASTUP")),2)<15
D SETFLRDH^HLCSUTL1(HLPTRFLR,"IN") ; Update LAST KNOWN $H (field #.03) for filer
S HLPTRFLR("LASTUP")=$H
D CHK4STOP^HLCSUTL2(HLPTRFLR,"IN",.HLEXIT) Q:HLEXIT
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HHLCSIN 6468 printed Dec 13, 2024@01:56:39 Page 2
HLCSIN ;ALB/JRP - INCOMING FILER;01-MAY-95 ;03/07/2011
+1 ;;1.6;HEALTH LEVEL SEVEN;**2,30,14,19,62,109,115,122,140,145,153,175**;Oct 13, 1995;Build 2
+2 ;Per VHA Directive 6402, this routine should not be modified.
+3 ;Supported ICR# 10063, for $$PSET^%ZTLOAD API to make task persistent
STARTIN ;Main entry point for incoming background filer
+1 ;Create/find entry denoting this filer in the INCOMING FILER TASK
+2 ; NUMBER multiple (field #20) of the HL COMMUNICATION SERVER PARAMETER
+3 ; file (#869.3)
+4 NEW HLFLG,HLEXIT,HLPTRFLR
+5 ;
+6 ; patch HL*1.6*122
+7 ;; N HLDUZ,DUZ ; patch HL*1.6*122 TEST v2: DUZ code removed
+8 NEW HLDUZ
+9 SET HLDUZ=+$GET(DUZ)
+10 ;
+11 ;;patch HL*1.6*175 adds the $$PSET^%ZTLOAD api to set filers to persistent
+12 NEW HLPERS
+13 IF $GET(ZTQUEUED)
Begin DoDot:1
+14 SET HLPERS=$$PSET^%ZTLOAD(ZTQUEUED)
End DoDot:1
+15 ;
+16 SET HLPTRFLR=+$$CRTFLR^HLCSUTL1(ZTSK,"IN")
+17 ;Loop through Logical Links and check for incoming messages
+18 SET HLEXIT=0
+19 ; patch HL*1.6*122 TEST v2: DUZ code removed
+20 ; patch HL*1.6*122, set DUZ for application proxy user
+21 ;; D PROXY^HLCSTCP4
+22 SET HLPTRFLR("$J")=$JOB
+23 FOR
Begin DoDot:1
+24 SET HLFLG=0
+25 DO DEFACK(.HLPTRFLR,.HLFLG,.HLEXIT)
if HLEXIT
QUIT
+26 DO ACKNOW(.HLPTRFLR,.HLFLG,.HLEXIT)
if HLEXIT
QUIT
+27 if HLFLG
QUIT
+28 IF $$HDIFF^XLFDT($HOROLOG,$GET(HLPTRFLR("LASTDEL")),2)>3600
Begin DoDot:2
+29 ; maintain queue sizes
SET HLPTRFLR("LASTDEL")=$HOROLOG
+30 ; no more than once an hour.
DO DELQUE(.HLPTRFLR,.HLEXIT)
End DoDot:2
QUIT
+31 ; patch HL*1.6*122
+32 ; H 5
+33 HANG 1
+34 DO CHKUPD(.HLPTRFLR,.HLEXIT)
if HLEXIT
QUIT
End DoDot:1
if HLEXIT
QUIT
+35 ;Asked to stop
SET ZTSTOP=1
+36 ;Delete entry denoting this filer
DO DELFLR^HLCSUTL1(HLPTRFLR,"IN")
+37 SET ZTREQ="@"
+38 QUIT
DEFACK(HLPTRFLR,HLFLG,HLEXIT) ; Process TCP links with a deferred response
+1 NEW HLXX,HLD0,HLPCT
+2 SET HLXX=0
+3 FOR
SET HLXX=$ORDER(^HLMA("AC","I",HLXX))
if 'HLXX
QUIT
Begin DoDot:1
+4 ; HL*1.6*122, check the in-queue stop flag
+5 if $PIECE($GET(^HLCS(870,HLXX,0)),"^",9)
QUIT
+6 DO CHKUPD(.HLPTRFLR,.HLEXIT)
if HLEXIT
QUIT
+7 ; patch HL*1.6*109: Does another filer have this?
+8 ; L +^HLMA("AC","I",HLXX):0 Q:'$T
+9 ; patch HL*1.6*140 - change the lock node, it conflicts with
+10 ; lock defined in routine, HLCSREP.
+11 ; L +^HLMA("AC","I",HLXX):2 Q:'$T ; patch HL*1.6*122
+12 ; patch HL*1.6*122
LOCK +^HLMA("IN-FILER","AC","I",HLXX):0
if '$TEST
QUIT
+13 SET HLD0=0
SET HLFLG=1
+14 ; HL*1.6*109 changes in for loop below, and post-quit code placed
+15 ; on following lines.
+16 ; Counter whether filer should stop every 100th entry.
SET HLPCT=0
+17 ;**109 - insure queue last processed at least 2 seconds ago
+18 ; patch HL*1.6*140
+19 ; I ($$HDIFF^XLFDT($H,$G(^XTMP("HL7-AC","I",HLXX)),2)<2) L -^HLMA("AC","I",HLXX) Q
+20 IF ($$HDIFF^XLFDT($HOROLOG,$GET(^XTMP("HL7-AC","I",HLXX)),2)<2)
LOCK -^HLMA("IN-FILER","AC","I",HLXX)
QUIT
+21 FOR
SET HLD0=$ORDER(^HLMA("AC","I",HLXX,HLD0))
if 'HLD0!(HLEXIT)
QUIT
Begin DoDot:2
+22 ; patch HL*1.6*122 start
+23 ; patch HL*1.6*122 TEST v2: DUZ code removed
+24 ; DUZ comparison/reset for application proxy user
+25 ;; D HLDUZ^HLCSTCP4
+26 DO HLDUZ2^HLCSTCP4
+27 ; protect HLDUZ
+28 NEW HLDUZ
+29 SET HLPCT=HLPCT+1
+30 IF '(HLPCT#100)
DO CHKUPD(.HLPTRFLR,.HLEXIT)
if HLEXIT
QUIT
+31 ; L +^HLMA(HLD0):0 Q:'$T
+32 FOR
LOCK +^HLMA(HLD0):30
if $TEST
QUIT
HANG 1
+33 ;-> Quit if not a valid AC xref
IF '$$CHECKAC("I",HLXX,HLD0)
LOCK -^HLMA(HLD0)
QUIT
+34 DO DEFACK^HLTP3(HLXX,HLD0)
+35 DO DEQUE^HLCSREP(HLXX,"I",HLD0)
+36 LOCK -^HLMA(HLD0)
+37 ; patch HL*1.6*145
+38 ; increment counter after message has been processed.
+39 DO LLCNT^HLCSTCP(HLXX,2)
End DoDot:2
+40 ; patch HL*1.6*122 end
+41 ;**109 -add dt/tm stamp to time queue last processed
+42 SET ^XTMP("HL7-AC","I",HLXX)=$HOROLOG
+43 ;**109 -unlock the queue
+44 ; patch HL*1.6*140
+45 ; L -^HLMA("AC","I",HLXX)
+46 LOCK -^HLMA("IN-FILER","AC","I",HLXX)
End DoDot:1
if HLEXIT
QUIT
+47 QUIT
+48 ;
CHECKAC(WAY,IEN870,IEN773) ; If AC xref shouldn't exist, kill it...
+1 ;
+2 ; Check status and if 3 (processed) kill XREF...
+3 ;->
IF $PIECE($GET(^HLMA(+IEN773,"P")),U)=3
Begin DoDot:1
+4 DO DEQUE^HLCSREP(IEN870,WAY,IEN773)
End DoDot:1
QUIT ""
+5 ;
+6 ; Add other checks here in the future...
+7 ;
+8 QUIT 1
+9 ;
ACKNOW(HLPTRFLR,HLFLG,HLEXIT) ; Process Logical Link's IN-queue for received message
+1 NEW HLXX,HLD0,HLD1
+2 SET HLXX=0
+3 FOR
SET HLXX=$ORDER(^HLCS(870,"AISTAT","P",HLXX))
if 'HLXX
QUIT
Begin DoDot:1
+4 ; HL*1.6*122, check the in-queue stop flag
+5 if $PIECE($GET(^HLCS(870,HLXX,0)),"^",9)
QUIT
+6 DO CHKUPD(.HLPTRFLR,.HLEXIT)
if HLEXIT
QUIT
+7 ; HL*1.6*109: Does another filer have this?
+8 ; L +^HLCS(870,HLXX,"INFILER"):0 Q:'$T
+9 ; patch HL*1.6*122
LOCK +^HLCS(870,HLXX,"INFILER"):2
if '$TEST
QUIT
+10 FOR
DO CHKUPD(.HLPTRFLR,.HLEXIT)
if HLEXIT
QUIT
SET HLD0=$$DEQUEUE^HLCSQUE(HLXX,"IN")
if +HLD0<0
QUIT
Begin DoDot:2
+11 ;
+12 ; patch HL*1.6*122 start
+13 ; clean variables except Kernel related variables
+14 Begin DoDot:3
+15 ; protect variables defined in STARTIN^HLCSIN
+16 NEW HLFLG,HLEXIT,HLPTRFLR
+17 NEW HLDUZ
+18 ; protect variables defined in ACKNOW^HLCSIN
+19 NEW HLXX,HLD0,HLD1
+20 DO KILL^XUSCLEAN
End DoDot:3
+21 ;
+22 ; patch HL*1.6*122 TEST v2: DUZ code removed
+23 ; DUZ comparison/reset for application proxy user
+24 ;; D HLDUZ^HLCSTCP4
+25 DO HLDUZ2^HLCSTCP4
+26 ; protect HLDUZ
+27 NEW HLDUZ
+28 ;Make sure message is ready to be received
+29 SET HLFLG=1
+30 SET HLD1=$PIECE(HLD0,"^",2)
+31 ; At this point, HLD0=HLXX
SET HLD0=+HLD0
+32 IF $PIECE($GET(^HLCS(870,HLD0,1,HLD1,0)),"^",3)'="A"
Begin DoDot:3
+33 ;Set status to DONE
DO MONITOR^HLCSDR2("D",2,HLD0,HLD1,"IN")
End DoDot:3
QUIT
+34 ;Process received message
DO RECEIVE^HLMA0(HLD0,HLD1)
+35 ;Set status to DONE
DO MONITOR^HLCSDR2("D",2,HLD0,HLD1,"IN")
End DoDot:2
+36 ; patch HL*1.6*122 end
+37 IF HLD0<0
IF $DATA(^HLCS(870,"AISTAT","P",HLXX))
Begin DoDot:2
+38 ; Make sure there aren't any loose xrefs hanging around.
SET HLD1=0
+39 FOR
SET HLD1=$ORDER(^HLCS(870,"AISTAT","P",HLXX,HLD1))
if 'HLD1
QUIT
Begin DoDot:3
+40 ;I '$D(^HLCS(870,HLXX,1,HLD1,0)) K ^HLCS(870,"AISTAT","P",HLXX,HLD1)
+41 IF $PIECE($GET(^HLCS(870,HLXX,1,HLD1,0)),U,2)'="P"
KILL ^HLCS(870,"AISTAT","P",HLXX,HLD1)
End DoDot:3
End DoDot:2
+42 LOCK -^HLCS(870,HLXX,"INFILER")
End DoDot:1
if HLEXIT
QUIT
+43 QUIT
DELQUE(HLPTRFLR,HLEXIT) ; Delete messages outside the 'queue size' window.
+1 NEW HLDIR,HLXX,HLFRONT
+2 SET HLDIR=1
SET HLXX=0
+3 FOR
SET HLXX=$ORDER(^HLCS(870,HLXX))
if 'HLXX
QUIT
Begin DoDot:1
+4 DO CHKUPD(.HLPTRFLR,.HLEXIT)
if HLEXIT
QUIT
+5 ; patch HL*1.6*122, comment out, no need to lock
+6 ; L +^HLCS(870,HLXX,"IN QUEUE FRONT POINTER"):0 Q:'$T
+7 SET HLFRONT=$GET(^HLCS(870,HLXX,"IN QUEUE FRONT POINTER"))
+8 ; patch HL*1.6*122, comment out
+9 ; L -^HLCS(870,HLXX,"IN QUEUE FRONT POINTER")
+10 DO DELETE^HLCSQUE1(HLXX,HLDIR,HLFRONT)
End DoDot:1
if HLEXIT
QUIT
+11 QUIT
CHKUPD(HLPTRFLR,HLEXIT) ;
+1 if $$HDIFF^XLFDT($HOROLOG,$GET(HLPTRFLR("LASTUP")),2)<15
QUIT
+2 ; Update LAST KNOWN $H (field #.03) for filer
DO SETFLRDH^HLCSUTL1(HLPTRFLR,"IN")
+3 SET HLPTRFLR("LASTUP")=$HOROLOG
+4 DO CHK4STOP^HLCSUTL2(HLPTRFLR,"IN",.HLEXIT)
if HLEXIT
QUIT
+5 QUIT