MPIHLO2 |
MPIHLO2 ;IRMFO-ALB/CJM -one time conversion of MPI's sequence
queues; 03/24/2004 14:43 ;07/29/2008
;;1.0;MASTER PATIENT INDEX AUSTIN;**73**;30 Apr 99
;
;pull record off of MPI LKMV out queue first
;example ^HLB("QUEUE","OUT","VAPSIM:5027","MPI
LKMV",586)=""
;example ^HLB("QUEUE","SEQUENCE","MPI LKMV")=586
<-- msg=586 has already been moved to the outque,
it is the msg that the sequence queue is waiting on
;example ^HLB("QUEUE","SEQUENCE","MPI LKMV",587)=""
<-- msg=588 is the next message ont he sequence queue
that needs to be moved to the out queue whenthe app
ack for msg 587 is received
;
;
N CNT,MPIQ,IEN
S CNT=0
S MPIQ="MPI LKMV"
S IEN=""
;
F S IEN=$O(^HLB("QUEUE","SEQUENCE",MPIQ,IEN)) Q:'IEN D
.I $$MOVE(IEN) S CNT=CNT+1
;
;decrement the counter for the sequence queues
I $$INC^HLOSITE($NA(^HLC("QUEUECOUNT","SEQUENCE")),-CNT)
W !,"MOVE COMPLETED. Count of records moved:",CNT
Q
;
MOVE(IEN) ;returns 1 if the msg was moved, 0 if it was not
N MOVED,BODY,ICN1,ICN2
S MOVED=0
;
S BODY=$P(^HLB(IEN,0),"^",2)
Q:'BODY 0
;
S ICN1=+$P($G(^HLA(BODY,1,3,0)),"^",4)
S ICN2=+$P($G(^HLA(BODY,1,6,0)),"^",4)
S:ICN2=0 ICN2=+$P($G(^HLA(BODY,1,7,0)),"^",4)
;add event
I ICN1=ICN2 D
.N MSG,OLDSEQ,OLDOUT,LINK,PORT,NEWQUE,FS,CS,EVENT
.Q:'$$GETMSG^HLOMSG(IEN,.MSG)
.S FS=$E(MSG("HDR",1),4)
.S CS=$E(MSG("HDR",1),5)
.S EVENT=$P($P(MSG("HDR",2),FS,4),CS,2)
.S OLDSEQ=$G(MSG("STATUS","SEQUENCE QUEUE"))
.;
.Q:EVENT'="A24"
.;
.S OLDOUT=$G(MSG("STATUS","QUEUE"))
.S LINK=$G(MSG("STATUS","LINK NAME"))
.S PORT=$G(MSG("STATUS","PORT"))
.S NEWQUE="MPI UPD"_$E(+ICN1,$L(+ICN1)-2,$L(+ICN1))
.Q:'$L(NEWQUE)
.I NEWQUE'=OLDOUT D
..;update the message to show the new outgoing queue
..S $P(^HLB(IEN,0),"^",6)=NEWQUE
.;
.;remove the msg from the sequence queue
.K ^HLB("QUEUE","SEQUENCE",OLDSEQ,IEN)
.;
.;put the msg on the outgoing queue
.D OUTQUE^HLOQUE(LINK,PORT,NEWQUE,IEN)
.;
.;node 5 can be killed - it makes it as if a sequence
queue was never involved
.K ^HLB(IEN,5)
.S MOVED=1
Q MOVED
|