Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: HLCSQUE1

HLCSQUE1.m

Go to the documentation of this file.
  1. HLCSQUE1 ;ALB/MFK HL7 UTILITY FUNCTIONS - 10/4/94 11AM ;05/08/2000 11:22 [ 12/23/2003 3:46 PM ]
  1. ;;1.6;HEALTH LEVEL SEVEN;**14,59,100,1005**;Oct 13, 1995
  1. ;
  1. ;Utilities used by HLCSQUE
  1. ;
  1. DELMSG(IEN,HLDIR,MSG) ;DELETE A SINGLE MESSAGE FROM A QUEUE
  1. ;INPUT: IEN - Internal Entry Number for queue
  1. ; HLDIR - Direction of queue
  1. ; MSG - Message number to remove
  1. ;OUTPUT: 0 - Success
  1. ; -1 - Error
  1. N DIK,DA
  1. ; Check for required variables
  1. S IEN=$G(IEN)
  1. Q:(IEN="") "-1^Internal Entry Number missing"
  1. I +IEN<1 S IEN=$O(^HLCS(870,"B",IEN,""))
  1. Q:(IEN="") "-1^Invalid IEN"
  1. S HLDIR=$G(HLDIR)
  1. S HLDIR=$S(HLDIR="IN":1,HLDIR="OUT":2,HLDIR=2:2,HLDIR=1:1,1:"")
  1. Q:(HLDIR="") "-1^Invalid direction"
  1. S MSG=$G(MSG)
  1. Q:(MSG="") "-1^No message number"
  1. L +^HLCS(870,IEN,HLDIR,MSG):1
  1. ;If lock fails, another process is doing the work.
  1. I '$T Q 1
  1. S DIK="^HLCS(870,"_IEN_","_HLDIR_",",DA(1)=IEN,DA=MSG
  1. D ^DIK
  1. L -^HLCS(870,IEN,HLDIR,MSG)
  1. K IEN,HLDIR,MSG
  1. Q 0
  1. DELETE(IEN,HLDIR,FRONT) ; Delete messages outside the 'queue size' window
  1. N MSG,TMP,QSIZE,STOP,HLX
  1. ; Make sure required variables exist
  1. S IEN=$G(IEN) Q:(IEN="")
  1. S HLDIR=$G(HLDIR) Q:(HLDIR="")
  1. S FRONT=$G(FRONT) Q:(FRONT="")
  1. S TMP=^HLCS(870,IEN,0)
  1. S QSIZE=$P(TMP,"^",21)
  1. I FRONT'>0 Q
  1. I QSIZE'>0 S QSIZE=10
  1. S MSG=0,STOP=0
  1. ; For each message from the beginning of the queue to the front
  1. ; of the queue-queue size, delete that message if it's done
  1. F S MSG=$O(^HLCS(870,IEN,HLDIR,MSG)) Q:(MSG>(FRONT-QSIZE))!(STOP'=0)!(MSG'>0) D
  1. .I $P($G(^HLCS(870,IEN,HLDIR,MSG,0)),"^",2)'="D" D QUIT:STOP ;->
  1. ..I $D(^HLCS(870,IEN,HLDIR,MSG)) D QUIT:STOP ;->
  1. ...S HLX=$O(^HLCS(870,IEN,HLDIR,MSG)) QUIT:HLX>0 ;->
  1. ...S STOP=1
  1. ..S HLX=+$G(HLX)
  1. ..I '$D(^HLCS(870,IEN,HLDIR,+HLX,0)) S STOP=1 QUIT ;->
  1. ..Q:$P($G(^HLCS(870,IEN,HLDIR,+HLX,0)),U,2)="D" ;-> All OK...
  1. ..S STOP=1
  1. .S STOP=$$DELMSG(IEN,HLDIR,MSG)
  1. K IEN,HLDIR,FRONT
  1. Q