Changeset 636 for FOIAVistA/tag/r/HEALTH_LEVEL_SEVEN-HL/HLOQUE.m
- Timestamp:
- Dec 4, 2009, 8:26:01 PM (14 years ago)
- 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 ;0 7/31/20072 ;;1.6;HEALTH LEVEL SEVEN;**126,132,134 ,137**;Oct 13, 1995;Build 211 HLOQUE ;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 3 3 ;Per VHA Directive 2004-038, this routine should not be modified. 4 4 ; … … 90 90 I $G(^HLTMP("STOPPED QUEUES",DIR,QUEUE)) Q 1 91 91 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 queue97 ; LINKNAME = name of (.01) the logical link98 ; PORT (optional) the port to connect to99 ; QNAME (optional) outgoing queue100 ; IEN778 = ien of the message in file 778101 ;Output: 1 if placed on the outgoing queue, 0 if placed on the sequence queue102 ;103 N NEXT,MOVED104 S MOVED=0105 ;106 ;keep a count of messages pending on sequence queues for the HLO System Monitor107 I $$INC^HLOSITE($NA(^HLC("QUEUECOUNT","SEQUENCE")))108 ;109 L +^HLB("QUEUE","SEQUENCE",SQUE):200110 ;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 queue114 I '$O(^HLB("QUEUE","SEQUENCE",SQUE,0)),'NEXT D115 .S ^HLB("QUEUE","SEQUENCE",SQUE)=IEN778 ;to mean something moved to outgoing but not yet transmitted116 .L -^HLB("QUEUE","SEQUENCE",SQUE)117 .D OUTQUE(.LINKNAME,.PORT,.QNAME,IEN778)118 .S MOVED=1119 E D120 .;Put the message on the sequence queue.121 .S ^HLB("QUEUE","SEQUENCE",SQUE,IEN778)=""122 .L -^HLB("QUEUE","SEQUENCE",SQUE)123 Q MOVED124 ;125 ADVANCE(SQUE,MSGIEN) ;126 ;Will move the specified sequencing queue to the next message.127 ;Input:128 ; SQUE - name of the sequencing queue129 ; 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 not132 ;133 N NODE,IEN778,LINKNAME,PORT,QNAME134 Q:'$L($G(SQUE)) 0135 Q:'$G(MSGIEN) 0136 L +^HLB("QUEUE","SEQUENCE",SQUE):200137 ;138 ;do not advance if the queue wasn't pending the message=MSGIEN139 I (MSGIEN'=$P($G(^HLB("QUEUE","SEQUENCE",SQUE)),"^")) L -^HLB("QUEUE","SEQUENCE",SQUE) Q 0140 ;141 I $$INC^HLOSITE($NA(^HLC("QUEUECOUNT","SEQUENCE")),-1)<0,$$INC^HLOSITE($NA(^HLC("QUEUECOUNT","SEQUENCE"))) ;decrement the count of messages pending sequence queues142 ;143 S IEN778=0144 ;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) D146 .;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 queues149 ;150 ;IEN778 is the next pending msg on this sequence queue151 I IEN778 D152 .;153 .;parse out info needed to move to outgoing queue154 .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 queue158 .L -^HLB("QUEUE","SEQUENCE",SQUE)159 .S $P(^HLB(IEN778,5),"^",2)=1160 .D OUTQUE(.LINKNAME,$G(PORT),$G(QNAME),IEN778) ;move to outgoing queue161 E D162 .K ^HLB("QUEUE","SEQUENCE",SQUE) ;this sequence queue is currently empty and not needed163 .L -^HLB("QUEUE","SEQUENCE",SQUE)164 Q 1165 ;166 SEQCHK(WORK) ;functions under the HLO Process Manager167 ;check sequence queues for timeout168 N QUE,NOW169 S NOW=$$NOW^XLFDT170 S QUE=""171 F S QUE=$O(^HLB("QUEUE","SEQUENCE",QUE)) Q:QUE="" D172 .N NODE,MSGIEN,ACTION,NODE173 .S NODE=$G(^HLB("QUEUE","SEQUENCE",QUE))174 .Q:'$P(NODE,"^",2)175 .Q:$P(NODE,"^",2)>NOW176 .Q:$P(NODE,"^",3)177 .L +^HLB("QUEUE","SEQUENCE",QUE):2178 .;don't report if a lock wasn't obtained179 .Q:'$T180 .S NODE=$G(^HLB("QUEUE","SEQUENCE",QUE))181 .I '$P(NODE,"^",2) L -^HLB("QUEUE","SEQUENCE",QUE) Q182 .I ($P(NODE,"^",2)>NOW) L -^HLB("QUEUE","SEQUENCE",QUE) Q183 .I $P(NODE,"^",3) L -^HLB("QUEUE","SEQUENCE",QUE) Q ;exception already raised184 .S MSGIEN=$P(NODE,"^")185 .I 'MSGIEN L -^HLB("QUEUE","SEQUENCE",QUE) Q186 .S ACTION=$$EXCEPT^HLOAPP($$GETSAP^HLOCLNT2(MSGIEN))187 .S $P(^HLB(MSGIEN,5),"^",3)=1188 .S $P(^HLB("QUEUE","SEQUENCE",QUE),"^",3)=1 ;indicates exception raised189 .L -^HLB("QUEUE","SEQUENCE",QUE)190 .D ;call the application to take action191 ..N HLMSGIEN,MCODE,DUZ,QUE,NOW192 ..N $ETRAP,$ESTACK S $ETRAP="G ERROR^HLOQUE"193 ..S HLMSGIEN=MSGIEN194 ..S MCODE="D "_ACTION195 ..N MSGIEN,X196 ..D DUZ^XUP(.5)197 ..X MCODE198 ..;kill the apps variables199 ..D200 ...N ZTSK201 ...D KILL^XUSCLEAN202 Q203 ERROR ;error trap for application context204 S $ETRAP="D UNWIND^%ZTER"205 D ^%ZTER206 S $ECODE=",UAPPLICATION ERROR,"207 ;208 ;kill the apps variables209 D210 .N ZTSK,MSGIEN,QUEUE211 .D KILL^XUSCLEAN212 ;213 ;release all the locks the app may have set, except Taskman lock214 L:$D(ZTSK) ^%ZTSCH("TASK",ZTSK):1215 L:'$D(ZTSK)216 ;reset HLO's lock217 L +^HLTMP("HL7 RUNNING PROCESSES",$J):0218 ;return to processing the next message on the queue219 D UNWIND^%ZTER220 Q
Note:
See TracChangeset
for help on using the changeset viewer.