Ignore:
Timestamp:
Dec 4, 2009, 8:26:01 PM (14 years ago)
Author:
George Lilly
Message:

WorldVistAEHR overlayed on FOIAVistA

Location:
FOIAVistA/tag/r
Files:
1 edited
1 copied

Legend:

Unmodified
Added
Removed
  • FOIAVistA/tag/r/HEALTH_LEVEL_SEVEN-HL/HLOQUE.m

    r628 r636  
    1 HLOQUE ;ALB/CJM- HL7 QUEUE MANAGEMENT - 10/4/94 1pm ;07/31/2007
    2  ;;1.6;HEALTH LEVEL SEVEN;**126,132,134,137**;Oct 13, 1995;Build 21
     1HLOQUE ;ALB/CJM- HL7 QUEUE MANAGEMENT - 10/4/94 1pm ;01/05/2007
     2 ;;1.6;HEALTH LEVEL SEVEN;**126,132,134**;Oct 13, 1995;Build 30
    33 ;Per VHA Directive 2004-038, this routine should not be modified.
    44 ;
     
    9090 I $G(^HLTMP("STOPPED QUEUES",DIR,QUEUE)) Q 1
    9191 Q 0
    92  ;
    93 SQUE(SQUE,LINKNAME,PORT,QNAME,IEN778) ;
    94  ;Will place the message=IEN778 on the sequencing queue. This is always done in the context of the application calling an HLO API to send a message.
    95  ;Input:
    96  ;  SQUE - name of the sequencing queue
    97  ;  LINKNAME = name of (.01) the logical link
    98  ;  PORT (optional) the port to connect to
    99  ;  QNAME (optional) outgoing queue
    100  ;  IEN778 = ien of the message in file 778
    101  ;Output: 1 if placed on the outgoing queue, 0 if placed on the sequence queue
    102  ;
    103  N NEXT,MOVED
    104  S MOVED=0
    105  ;
    106  ;keep a count of messages pending on sequence queues for the HLO System Monitor
    107  I $$INC^HLOSITE($NA(^HLC("QUEUECOUNT","SEQUENCE")))
    108  ;
    109  L +^HLB("QUEUE","SEQUENCE",SQUE):200
    110  ;
    111  S NEXT=+$G(^HLB("QUEUE","SEQUENCE",SQUE))
    112  Q:NEXT=IEN778 0  ;already queued!
    113  ;if the sequence queue is empty and not waiting on a message, then the message can be put directly on the outgoing queue, bypassing the sequence queue
    114  I '$O(^HLB("QUEUE","SEQUENCE",SQUE,0)),'NEXT D
    115  .S ^HLB("QUEUE","SEQUENCE",SQUE)=IEN778 ;to mean something moved to outgoing but not yet transmitted
    116  .L -^HLB("QUEUE","SEQUENCE",SQUE)
    117  .D OUTQUE(.LINKNAME,.PORT,.QNAME,IEN778)
    118  .S MOVED=1
    119  E  D
    120  .;Put the message on the sequence queue.
    121  .S ^HLB("QUEUE","SEQUENCE",SQUE,IEN778)=""
    122  .L -^HLB("QUEUE","SEQUENCE",SQUE)
    123  Q MOVED
    124  ;
    125 ADVANCE(SQUE,MSGIEN) ;
    126  ;Will move the specified sequencing queue to the next message.
    127  ;Input:
    128  ;  SQUE - name of the sequencing queue
    129  ;  MSGIEN - the ien of the message upon which the sequence queue was waiting.  If it is NOT the correct ien, then the sequence queue will NOT be advance.
    130  ;Output:
    131  ;  Function - 1 if advanced, 0 if not
    132  ;
    133  N NODE,IEN778,LINKNAME,PORT,QNAME
    134  Q:'$L($G(SQUE)) 0
    135  Q:'$G(MSGIEN) 0
    136  L +^HLB("QUEUE","SEQUENCE",SQUE):200
    137  ;
    138  ;do not advance if the queue wasn't pending the message=MSGIEN
    139  I (MSGIEN'=$P($G(^HLB("QUEUE","SEQUENCE",SQUE)),"^")) L -^HLB("QUEUE","SEQUENCE",SQUE) Q 0
    140  ;
    141  I $$INC^HLOSITE($NA(^HLC("QUEUECOUNT","SEQUENCE")),-1)<0,$$INC^HLOSITE($NA(^HLC("QUEUECOUNT","SEQUENCE"))) ;decrement the count of messages pending sequence queues
    142  ;
    143  S IEN778=0
    144  ;look for the first message on the sequence que.  Make sure its valid, if not remove the invalid entry and keep looking.
    145  F  S IEN778=$O(^HLB("QUEUE","SEQUENCE",SQUE,0)) Q:'IEN778  S NODE=$G(^HLB(IEN778,0)) Q:$L(NODE)  D
    146  .;message does not exist! Remove from queue and try again.
    147  .K ^HLB("QUEUE","SEQUENCE",SQUE,IEN778)
    148  .I $$INC^HLOSITE($NA(^HLC("QUEUECOUNT","SEQUENCE")),-1)<0,$$INC^HLOSITE($NA(^HLC("QUEUECOUNT","SEQUENCE"))) ;decrement the count of messages pending sequence queues
    149  ;
    150  ;IEN778 is the next pending msg on this sequence queue
    151  I IEN778 D
    152  .;
    153  .;parse out info needed to move to outgoing queue
    154  .S LINKNAME=$P(NODE,"^",5),PORT=$P(NODE,"^",8),QNAME=$P(NODE,"^",6)
    155  .;
    156  .S ^HLB("QUEUE","SEQUENCE",SQUE)=IEN778 ;indicates this sequence queue is now waiting for msg=IEN778 before advancing.  The second pieces is the timer, but will not be set until the message=IEN778 is actually transmitted.
    157  .K ^HLB("QUEUE","SEQUENCE",SQUE,IEN778) ;remove from sequence queue
    158  .L -^HLB("QUEUE","SEQUENCE",SQUE)
    159  .S $P(^HLB(IEN778,5),"^",2)=1
    160  .D OUTQUE(.LINKNAME,$G(PORT),$G(QNAME),IEN778) ;move to outgoing queue
    161  E  D
    162  .K ^HLB("QUEUE","SEQUENCE",SQUE) ;this sequence queue is currently empty and not needed
    163  .L -^HLB("QUEUE","SEQUENCE",SQUE)
    164  Q 1
    165  ;
    166 SEQCHK(WORK) ;functions under the HLO Process Manager
    167  ;check sequence queues for timeout
    168  N QUE,NOW
    169  S NOW=$$NOW^XLFDT
    170  S QUE=""
    171  F  S QUE=$O(^HLB("QUEUE","SEQUENCE",QUE)) Q:QUE=""  D
    172  .N NODE,MSGIEN,ACTION,NODE
    173  .S NODE=$G(^HLB("QUEUE","SEQUENCE",QUE))
    174  .Q:'$P(NODE,"^",2)
    175  .Q:$P(NODE,"^",2)>NOW
    176  .Q:$P(NODE,"^",3)
    177  .L +^HLB("QUEUE","SEQUENCE",QUE):2
    178  .;don't report if a lock wasn't obtained
    179  .Q:'$T
    180  .S NODE=$G(^HLB("QUEUE","SEQUENCE",QUE))
    181  .I '$P(NODE,"^",2) L -^HLB("QUEUE","SEQUENCE",QUE) Q
    182  .I ($P(NODE,"^",2)>NOW) L -^HLB("QUEUE","SEQUENCE",QUE) Q
    183  .I $P(NODE,"^",3) L -^HLB("QUEUE","SEQUENCE",QUE) Q  ;exception already raised
    184  .S MSGIEN=$P(NODE,"^")
    185  .I 'MSGIEN L -^HLB("QUEUE","SEQUENCE",QUE) Q
    186  .S ACTION=$$EXCEPT^HLOAPP($$GETSAP^HLOCLNT2(MSGIEN))
    187  .S $P(^HLB(MSGIEN,5),"^",3)=1
    188  .S $P(^HLB("QUEUE","SEQUENCE",QUE),"^",3)=1 ;indicates exception raised
    189  .L -^HLB("QUEUE","SEQUENCE",QUE)
    190  .D  ;call the application to take action
    191  ..N HLMSGIEN,MCODE,DUZ,QUE,NOW
    192  ..N $ETRAP,$ESTACK S $ETRAP="G ERROR^HLOQUE"
    193  ..S HLMSGIEN=MSGIEN
    194  ..S MCODE="D "_ACTION
    195  ..N MSGIEN,X
    196  ..D DUZ^XUP(.5)
    197  ..X MCODE
    198  ..;kill the apps variables
    199  ..D
    200  ...N ZTSK
    201  ...D KILL^XUSCLEAN
    202  Q
    203 ERROR ;error trap for application context
    204  S $ETRAP="D UNWIND^%ZTER"
    205  D ^%ZTER
    206  S $ECODE=",UAPPLICATION ERROR,"
    207  ;
    208  ;kill the apps variables
    209  D
    210  .N ZTSK,MSGIEN,QUEUE
    211  .D KILL^XUSCLEAN
    212  ;
    213  ;release all the locks the app may have set, except Taskman lock
    214  L:$D(ZTSK) ^%ZTSCH("TASK",ZTSK):1
    215  L:'$D(ZTSK)
    216  ;reset HLO's lock
    217  L +^HLTMP("HL7 RUNNING PROCESSES",$J):0
    218  ;return to processing the next message on the queue
    219  D UNWIND^%ZTER
    220  Q
Note: See TracChangeset for help on using the changeset viewer.