PSXQRY ;BIR/WPB,BAB-Sends/Receives the Query ;[ 10/23/97 6:59 AM ]
;;2.0;CMOP;**9**;11 Apr 97
EN D NOW^%DTC S XZ=$P(^PSX(553.1,0),"^",3),INT=$P(^PSX(553,1,0),"^",9) S:$G(INT)'>0 INT=1
I $G(XZ) S LQRYTM=$P(^PSX(553.1,XZ,0),"^",2) I %'>$$FMADD^XLFDT(LQRYTM,0,$G(INT),0,0) G ^PSXJOB
S (PSXCNT,PSXTRYN,RXCNT)=0,QLR=$P($G(^PSX(553,1,0)),"^",8)
S (DA,X)=$P(^PSX(553.1,0),U,3)+1,DIC="^PSX(553.1,",DIC(0)="LZ",DIC("DR")="1////"_%_";4////1",DLAYGO=553.1
F D FILE^DICN S PSXQRYID=+Y,LOG(1)="QUERY # "_PSXQRYID_" initiated."_$G(PSXQRYA) D LOG^PSXUTL
K DA,DIC,DUOUT,DTOUT,DLAYGO,X,Y,%,DINUM,PSXPOP,TRY
S PSXQRY=1 D BID^PSXMST G:$G(PSXQUIT) TST
D TSOUT^PSXUTL
S PSXBLK=1,PSXLAST=0
S PSXTXT="MSH|^~\&|DHCP||"_$S($G(PSXVNDR)>0:"SI BAKER",1:"ELECTROCOM")_"||"_PSXTS_"||QRY|"_PSXQRYID_"|P|2.1|" D XMIT^PSXSND G:$G(PSXPOP) TST
S PSXBLK=2,PSXLAST=1 S PSXTXT="QRD|"_PSXTS_"|R|I|"_PSXQRYID_"|||"_QLR_"^ZO|OP|OTH|ALL" D XMIT^PSXSND G:$G(PSXPOP) TST
W *EOT,*TERM
D SLAVE
TST D FLUSH1^PSXUTL
S LOG(1)="QUERY # "_PSXQRYID_" completed."_$G(PSXQRYA) S:$G(PSXSTOP) LOG(2)="DHCP STOPPED QUERY "_$G(PSXQRYID) S:$G(PSXQUIT) LOG(3)="No Response to Bid, DHCP terminated query." D LOG^PSXUTL
S $P(^PSX(554,1,0),"^",3)=PSXQRYID
S:$G(PSXQRYA) ^PSX(553,1,"S")="S"
K PSXHEX,PSXACK,LOG,BLK,BLKA,PSXQRYID,PSXTXT,PSXBLK,%,X,Y,PSXLAST,QLR,MESSID,MSGID,RXCNT,PSXQRY,PSXQRYA,PSXSTOP,PSXPOP,PSXQUIT
G ^PSXJOB
NAK D FLUSH1^PSXUTL,LOG^PSXUTL
W *NAK,*TERM
S PSXTRYN=PSXTRYN+1 G:PSXTRYN>5 ERROR G MSG
ND I $G(^PSX(553,1,"S"))="S" S PSXSTOP=1 Q
D QRY20,FLUSH1^PSXUTL,LOG^PSXUTL S PSXTRYN=PSXTRYN+1 G:PSXTRYN>5 ERROR G MSG
RTN G:PSXCNT'>1 SLAVE
Q:$G(PSXQRY)=0
D BID^PSXMST G:$G(PSXQUIT) TST D TSOUT^PSXUTL K PSXTXT,PSXLAST S PSXBLK=1,PSXLAST=0
S PSXTXT="MSH|^~\&|DHCP||"_$S($G(PSXVNDR)>0:"SI BAKER",1:"ELECTROCOM")_"||"_PSXTS_"||ACK|"_$G(MSGID)_"|P|2.1|" D XMIT^PSXSND Q:$G(PSXPOP)
S PSXBLK=2,PSXLAST=1
S PSXTXT="MSA|"_$S(QRYFLG=0:"AA|"_$G(MSGID)_"|",QRYFLG>0:"AR|"_MSGID_"|"_$S(QRYFLG=1:"RX NUMBER",QRYFLG=2:"STATUS",QRYFLG=3:"COMPLETED DATE",QRYFLG=4:"EMPLOYEE ID",QRYFLG=5:"NO CANCELLED REASON",1:"UNKNOWN")) D XMIT^PSXSND Q:$G(PSXPOP)
;I $G(QRYFLG)>0 S:$G(CANFLAG)>0 DA=XDA,DR="1////1",DIE="^PSX(552.3," D ^DIE K DA,DR,DIE,XDA S RXCNT=RXCNT-1
I $G(QRYFLG)>0 S DR="1////1",DIE="^PSX(552.3," F I=2:1 S XX=$P(XDA,"^",I) Q:XX'>0 S DA=XX D ^DIE K DA
I $G(QRYFLG)>0 K DA,DIE,DR
W *EOT,*TERM
D NOW^%DTC
S $P(^PSX(553.1,PSXQRYID,0),"^",4)=%,$P(^PSX(553.1,PSXQRYID,0),"^",5)=5,$P(^PSX(553.1,PSXQRYID,0),"^",6)=$G(RXCNT)
K MESSID,MSGID,TRY,CANFLAG
I $G(^PSX(553,1,"S"))="S" S PSXSTOP=1 Q
SLAVE S BLKA=0
R *X:PSXDLTD E D
E D QRY1,LOG^PSXUTL G ND
I X'=ENQ D QRY5 S TRY=$G(TRY)+1 G:$G(TRY)'>5 SLAVE G ERROR
R *X:PSXDLTA
I ('$T)!(X'=TERM) D QRY14 G ERROR
W *ACK,0,*TERM
R *X:PSXDLTD G:X=STX READ I X=EOT R *X:PSXDLTA Q:X=TERM
MSG R *X:PSXDLTD E D QRY1,LOG^PSXUTL G ND
I X=STX G READ
I X=EOT R *X:PSXDLTA I X=TERM G RTN
S QF="STX/EOT"
D QRY5 ;unexpected character received
ERROR D FLUSH1^PSXUTL,LOG^PSXUTL S QRYPOP=1
Q
READ S PSXACK="" S PSXTMD=$P($H,",",2)
GETMSG F %=1:1 D Q:'%
.R *X:PSXDLTA E D QRY6,LOG^PSXUTL S %=0,X="" Q
.D CHKD^PSXUTL I PSXTMOUT D QRY6,LOG^PSXUTL S %=0,X="" Q
.I %>240 D QRY7,LOG^PSXUTL S %=0,X="" Q
.S PSXACK=PSXACK_$C(X)
.I (X=ETX)!(X=ETB) S %=0
I X=ETX S PSXCNT=PSXCNT+1 G TEST
I X=ETB G TEST
I X=EOT R *X:PSXDLTA G:X=TERM MSG
I (X'=ETX)!(X'=ETB)!(X'=EOT) D QRY8 G NAK
I PSXACK="" D QRY9 G ERROR
Q
TEST R *X:PSXDLTA E D QRY10 G ERROR
I "0123456789ABCDEF"'[$C(X) D QRY11 G NAK
S PSXSUM=$C(X)
CHKSUM R *X:PSXDLTA E D QRY10 G ERROR
I "0123456789ABCDEF"'[$C(X) D QRY11 G NAK
S PSXSUM=PSXSUM_$C(X)
S X=PSXACK X ^%ZOSF("LPC") S PSXHEX=Y D HEX^PSXUTL
R *X:1 I X'=TERM D QRY5
I PSXHEX'=PSXSUM D QRY12 G NAK
I PSXHEX=PSXSUM D FLUSH1^PSXUTL
S BLK=$E(PSXACK,1) I BLK>7 D QRY16 G NAK
I RXCNT=QLR&($E(PSXACK,7,10)'["BTS") D QRY19,LOG^PSXUTL W *EOT,*TERM Q
I $E(PSXACK,7,10)["BTS|" S PSXQRY=0 S DA=PSXQRYID,DIE="^PSX(553.1,",DR="4////1" S:RXCNT=0 PSXCNT=2 D ^DIE K DR,DA,DIE
I $E(PSXACK,7,9)["MSA"&($P(PSXACK,"|",3)'=PSXQRYID) D QRY15 G NAK
I $E(PSXACK,7,9)["QRD"&($P(PSXACK,"|",5)'=PSXQRYID) D QRY15 G NAK
W *ACK,BLK,*TERM D FILE G MSG
Q
FILE I $E(PSXACK,7,10)["MSH|" S MESSID=$E(PSXACK,7,$L(PSXACK)-2),MSGID=$P(MESSID,"|",10),QRYFLG=0,XDA=""
I $E(PSXACK,7,12)["NTE|99" D
.S CANFLAG=0
.S:($P($P(PSXACK,"\",1),"|",4)="")!($P($P(PSXACK,"\",1),"|",4)[" ") QRYFLG=1 Q:QRYFLG>0 S:"CACO"'[$P(PSXACK,"\F\",2) QRYFLG=2 S:$P(PSXACK,"\F\",2)["CA" CANFLAG=1 Q:QRYFLG>0
.S:$P(PSXACK,"\F\",3)'?10.14N QRYFLG=3 Q:QRYFLG>0 S EMPID=$P(PSXACK,"\F\",5) S:$G(EMPID)="" QRYFLG=4 Q:QRYFLG>0 S:'$D(^VA(200,$G(EMPID),0)) QRYFLG=4 Q:QRYFLG>0 S:'$D(^XUSEC("PSXRPH",EMPID)) QRYFLG=4 Q:QRYFLG>0
.S RXCNT=RXCNT+1
I $E(PSXACK,7,13)["NTE|100" S:($G(CANFLAG)>0&($P($P(PSXACK,"\",1),"|",4)="")) QRYFLG=5
Q:BLK=BLKA
Q:$G(QRYFLG)>0
F1 L +^PSX(552.3,0):3 G:'$T F1 S NEW=$P(^PSX(552.3,0),"^",3)+1,$P(^PSX(552.3,0),"^",4)=$P(^PSX(552.3,0),"^",4)+1,$P(^PSX(552.3,0),"^",3)=NEW L -^PSX(552.3,0)
G:$D(^PSX(552.3,NEW,0)) F1
F2 L +^PSX(552.3,NEW):3 G:'$T F2 S ^PSX(552.3,NEW,0)=$E(PSXACK,7,$L(PSXACK)-2),^PSX(552.3,NEW,1)=2,^PSX(552.3,"AQ",NEW)="" L -^PSX(552.3,NEW) S XDA=$G(XDA)_"^"_NEW K NEW
S BLKA=BLK
Q
QRY1 K LOG S LOG(1)="QRY1 QRY message never received for query #"_PSXQRYID Q
QRY2 K LOG S LOG(1)="QRY2 EOT received with no terminator while waiting for QRY message" Q
QRY3 K LOG S LOG(1)="QRY3 EOT received while waiting for QRY message" Q
QRY5 ;K LOG S LOG(1)="QRY5 Unexpected character received: "_$S(X>31:$C(X),1:"")_" ("_X_") while waiting for QRY message" Q
K LOG S LOG(1)="QRY5 Unexpected character received: "_X_"^"_$G(QF) Q
QRY6 K LOG S LOG(1)="QRY6 Timeout Timer D reading QRY message" Q
QRY7 K LOG S LOG(1)="QRY7 QRY message longer than 240 characters" Q
QRY8 K LOG S LOG(1)="QRY8 QRY message did not end with ETX" Q
QRY9 K LOG S LOG(1)="QRY9 QRY was null" Q
QRY10 K LOG S LOG(1)="QRY10 Timeout reading QRY checksum" Q
QRY11 K LOG S LOG(1)="QRY11 QRY checksum contained an invalid hex digit ("_X_")" Q
QRY12 K LOG S LOG(1)="QRY12 QRY checksum does not match" Q
QRY13 K LOG S LOG(1)="QRY13 Message #"_PSXQRYID_" was rejected by OMCS" Q
QRY14 K LOG S LOG(1)="QRY14 ENQ received with no terminator" Q
QRY15 K LOG S LOG(1)="QRY15 MSA message ID did not match PSXQRYID # expected" Q
QRY16 K LOG S LOG(1)="QRY16 Block count greater than 7." Q
QRY17 K LOG S LOG(1)="QRY17 Wrong Block count received." Q
QRY18 K LOG S LOG(1)="QRY18 Maximum retries reached for receiving message." Q
QRY19 K LOG S LOG(1)="QRY19 Maximum Rxs received, query terminated." Q
QRY20 K LOG S LOG(1)="QRY20 No activity on line continuing to monitor." Q
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPSXQRY 6766 printed Dec 13, 2024@01:44:44 Page 2
PSXQRY ;BIR/WPB,BAB-Sends/Receives the Query ;[ 10/23/97 6:59 AM ]
+1 ;;2.0;CMOP;**9**;11 Apr 97
EN DO NOW^%DTC
SET XZ=$PIECE(^PSX(553.1,0),"^",3)
SET INT=$PIECE(^PSX(553,1,0),"^",9)
if $GET(INT)'>0
SET INT=1
+1 IF $GET(XZ)
SET LQRYTM=$PIECE(^PSX(553.1,XZ,0),"^",2)
IF %'>$$FMADD^XLFDT(LQRYTM,0,$GET(INT),0,0)
GOTO ^PSXJOB
+2 SET (PSXCNT,PSXTRYN,RXCNT)=0
SET QLR=$PIECE($GET(^PSX(553,1,0)),"^",8)
+3 SET (DA,X)=$PIECE(^PSX(553.1,0),U,3)+1
SET DIC="^PSX(553.1,"
SET DIC(0)="LZ"
SET DIC("DR")="1////"_%_";4////1"
SET DLAYGO=553.1
F DO FILE^DICN
SET PSXQRYID=+Y
SET LOG(1)="QUERY # "_PSXQRYID_" initiated."_$GET(PSXQRYA)
DO LOG^PSXUTL
+1 KILL DA,DIC,DUOUT,DTOUT,DLAYGO,X,Y,%,DINUM,PSXPOP,TRY
+2 SET PSXQRY=1
DO BID^PSXMST
if $GET(PSXQUIT)
GOTO TST
+3 DO TSOUT^PSXUTL
+4 SET PSXBLK=1
SET PSXLAST=0
+5 SET PSXTXT="MSH|^~\&|DHCP||"_$SELECT($GET(PSXVNDR)>0:"SI BAKER",1:"ELECTROCOM")_"||"_PSXTS_"||QRY|"_PSXQRYID_"|P|2.1|"
DO XMIT^PSXSND
if $GET(PSXPOP)
GOTO TST
+6 SET PSXBLK=2
SET PSXLAST=1
SET PSXTXT="QRD|"_PSXTS_"|R|I|"_PSXQRYID_"|||"_QLR_"^ZO|OP|OTH|ALL"
DO XMIT^PSXSND
if $GET(PSXPOP)
GOTO TST
+7 WRITE *EOT,*TERM
+8 DO SLAVE
TST DO FLUSH1^PSXUTL
+1 SET LOG(1)="QUERY # "_PSXQRYID_" completed."_$GET(PSXQRYA)
if $GET(PSXSTOP)
SET LOG(2)="DHCP STOPPED QUERY "_$GET(PSXQRYID)
if $GET(PSXQUIT)
SET LOG(3)="No Response to Bid, DHCP terminated query."
DO LOG^PSXUTL
+2 SET $PIECE(^PSX(554,1,0),"^",3)=PSXQRYID
+3 if $GET(PSXQRYA)
SET ^PSX(553,1,"S")="S"
+4 KILL PSXHEX,PSXACK,LOG,BLK,BLKA,PSXQRYID,PSXTXT,PSXBLK,%,X,Y,PSXLAST,QLR,MESSID,MSGID,RXCNT,PSXQRY,PSXQRYA,PSXSTOP,PSXPOP,PSXQUIT
+5 GOTO ^PSXJOB
NAK DO FLUSH1^PSXUTL
DO LOG^PSXUTL
+1 WRITE *NAK,*TERM
+2 SET PSXTRYN=PSXTRYN+1
if PSXTRYN>5
GOTO ERROR
GOTO MSG
ND IF $GET(^PSX(553,1,"S"))="S"
SET PSXSTOP=1
QUIT
+1 DO QRY20
DO FLUSH1^PSXUTL
DO LOG^PSXUTL
SET PSXTRYN=PSXTRYN+1
if PSXTRYN>5
GOTO ERROR
GOTO MSG
RTN if PSXCNT'>1
GOTO SLAVE
+1 if $GET(PSXQRY)=0
QUIT
+2 DO BID^PSXMST
if $GET(PSXQUIT)
GOTO TST
DO TSOUT^PSXUTL
KILL PSXTXT,PSXLAST
SET PSXBLK=1
SET PSXLAST=0
+3 SET PSXTXT="MSH|^~\&|DHCP||"_$SELECT($GET(PSXVNDR)>0:"SI BAKER",1:"ELECTROCOM")_"||"_PSXTS_"||ACK|"_$GET(MSGID)_"|P|2.1|"
DO XMIT^PSXSND
if $GET(PSXPOP)
QUIT
+4 SET PSXBLK=2
SET PSXLAST=1
+5 SET PSXTXT="MSA|"_$SELECT(QRYFLG=0:"AA|"_$GET(MSGID)_"|",QRYFLG>0:"AR|"_MSGID_"|"_$SELECT(QRYFLG=1:"RX NUMBER",QRYFLG=2:"STATUS",QRYFLG=3:"COMPLETED DATE",QRYFLG=4:"EMPLOYEE ID",QRYFLG=5:"NO CANCELLED REASON",1:"UNKNOWN"))
DO XMIT^PSXSND
if $GET(PSXPOP)
QUIT
+6 ;I $G(QRYFLG)>0 S:$G(CANFLAG)>0 DA=XDA,DR="1////1",DIE="^PSX(552.3," D ^DIE K DA,DR,DIE,XDA S RXCNT=RXCNT-1
+7 IF $GET(QRYFLG)>0
SET DR="1////1"
SET DIE="^PSX(552.3,"
FOR I=2:1
SET XX=$PIECE(XDA,"^",I)
if XX'>0
QUIT
SET DA=XX
DO ^DIE
KILL DA
+8 IF $GET(QRYFLG)>0
KILL DA,DIE,DR
+9 WRITE *EOT,*TERM
+10 DO NOW^%DTC
+11 SET $PIECE(^PSX(553.1,PSXQRYID,0),"^",4)=%
SET $PIECE(^PSX(553.1,PSXQRYID,0),"^",5)=5
SET $PIECE(^PSX(553.1,PSXQRYID,0),"^",6)=$GET(RXCNT)
+12 KILL MESSID,MSGID,TRY,CANFLAG
+13 IF $GET(^PSX(553,1,"S"))="S"
SET PSXSTOP=1
QUIT
SLAVE SET BLKA=0
+1 READ *X:PSXDLTD
IF '$TEST
Begin DoDot:1
End DoDot:1
+2 IF '$TEST
DO QRY1
DO LOG^PSXUTL
GOTO ND
+3 IF X'=ENQ
DO QRY5
SET TRY=$GET(TRY)+1
if $GET(TRY)'>5
GOTO SLAVE
GOTO ERROR
+4 READ *X:PSXDLTA
+5 IF ('$TEST)!(X'=TERM)
DO QRY14
GOTO ERROR
+6 WRITE *ACK,0,*TERM
+7 READ *X:PSXDLTD
if X=STX
GOTO READ
IF X=EOT
READ *X:PSXDLTA
if X=TERM
QUIT
MSG READ *X:PSXDLTD
IF '$TEST
DO QRY1
DO LOG^PSXUTL
GOTO ND
+1 IF X=STX
GOTO READ
+2 IF X=EOT
READ *X:PSXDLTA
IF X=TERM
GOTO RTN
+3 SET QF="STX/EOT"
+4 ;unexpected character received
DO QRY5
ERROR DO FLUSH1^PSXUTL
DO LOG^PSXUTL
SET QRYPOP=1
+1 QUIT
READ SET PSXACK=""
SET PSXTMD=$PIECE($HOROLOG,",",2)
GETMSG FOR %=1:1
Begin DoDot:1
+1 READ *X:PSXDLTA
IF '$TEST
DO QRY6
DO LOG^PSXUTL
SET %=0
SET X=""
QUIT
+2 DO CHKD^PSXUTL
IF PSXTMOUT
DO QRY6
DO LOG^PSXUTL
SET %=0
SET X=""
QUIT
+3 IF %>240
DO QRY7
DO LOG^PSXUTL
SET %=0
SET X=""
QUIT
+4 SET PSXACK=PSXACK_$CHAR(X)
+5 IF (X=ETX)!(X=ETB)
SET %=0
End DoDot:1
if '%
QUIT
+6 IF X=ETX
SET PSXCNT=PSXCNT+1
GOTO TEST
+7 IF X=ETB
GOTO TEST
+8 IF X=EOT
READ *X:PSXDLTA
if X=TERM
GOTO MSG
+9 IF (X'=ETX)!(X'=ETB)!(X'=EOT)
DO QRY8
GOTO NAK
+10 IF PSXACK=""
DO QRY9
GOTO ERROR
+11 QUIT
TEST READ *X:PSXDLTA
IF '$TEST
DO QRY10
GOTO ERROR
+1 IF "0123456789ABCDEF"'[$CHAR(X)
DO QRY11
GOTO NAK
+2 SET PSXSUM=$CHAR(X)
CHKSUM READ *X:PSXDLTA
IF '$TEST
DO QRY10
GOTO ERROR
+1 IF "0123456789ABCDEF"'[$CHAR(X)
DO QRY11
GOTO NAK
+2 SET PSXSUM=PSXSUM_$CHAR(X)
+3 SET X=PSXACK
XECUTE ^%ZOSF("LPC")
SET PSXHEX=Y
DO HEX^PSXUTL
+4 READ *X:1
IF X'=TERM
DO QRY5
+5 IF PSXHEX'=PSXSUM
DO QRY12
GOTO NAK
+6 IF PSXHEX=PSXSUM
DO FLUSH1^PSXUTL
+7 SET BLK=$EXTRACT(PSXACK,1)
IF BLK>7
DO QRY16
GOTO NAK
+8 IF RXCNT=QLR&($EXTRACT(PSXACK,7,10)'["BTS")
DO QRY19
DO LOG^PSXUTL
WRITE *EOT,*TERM
QUIT
+9 IF $EXTRACT(PSXACK,7,10)["BTS|"
SET PSXQRY=0
SET DA=PSXQRYID
SET DIE="^PSX(553.1,"
SET DR="4////1"
if RXCNT=0
SET PSXCNT=2
DO ^DIE
KILL DR,DA,DIE
+10 IF $EXTRACT(PSXACK,7,9)["MSA"&($PIECE(PSXACK,"|",3)'=PSXQRYID)
DO QRY15
GOTO NAK
+11 IF $EXTRACT(PSXACK,7,9)["QRD"&($PIECE(PSXACK,"|",5)'=PSXQRYID)
DO QRY15
GOTO NAK
+12 WRITE *ACK,BLK,*TERM
DO FILE
GOTO MSG
+13 QUIT
FILE IF $EXTRACT(PSXACK,7,10)["MSH|"
SET MESSID=$EXTRACT(PSXACK,7,$LENGTH(PSXACK)-2)
SET MSGID=$PIECE(MESSID,"|",10)
SET QRYFLG=0
SET XDA=""
+1 IF $EXTRACT(PSXACK,7,12)["NTE|99"
Begin DoDot:1
+2 SET CANFLAG=0
+3 if ($PIECE($PIECE(PSXACK,"\",1),"|",4)="")!($PIECE($PIECE(PSXACK,"\",1),"|",4)[" ")
SET QRYFLG=1
if QRYFLG>0
QUIT
if "CACO"'[$PIECE(PSXACK,"\F\",2)
SET QRYFLG=2
if $PIECE(PSXACK,"\F\",2)["CA"
SET CANFLAG=1
if QRYFLG>0
QUIT
+4 if $PIECE(PSXACK,"\F\",3)'?10.14N
SET QRYFLG=3
if QRYFLG>0
QUIT
SET EMPID=$PIECE(PSXACK,"\F\",5)
if $GET(EMPID)=""
SET QRYFLG=4
if QRYFLG>0
QUIT
if '$DATA(^VA(200,$GET(EMPID),0))
SET QRYFLG=4
if QRYFLG>0
QUIT
if '$DATA(^XUSEC("PSXRPH",EMPID))
SET QRYFLG=4
if QRYFLG>0
QUIT
+5 SET RXCNT=RXCNT+1
End DoDot:1
+6 IF $EXTRACT(PSXACK,7,13)["NTE|100"
if ($GET(CANFLAG)>0&($PIECE($PIECE(PSXACK,"\",1),"|",4)=""))
SET QRYFLG=5
+7 if BLK=BLKA
QUIT
+8 if $GET(QRYFLG)>0
QUIT
F1 LOCK +^PSX(552.3,0):3
if '$TEST
GOTO F1
SET NEW=$PIECE(^PSX(552.3,0),"^",3)+1
SET $PIECE(^PSX(552.3,0),"^",4)=$PIECE(^PSX(552.3,0),"^",4)+1
SET $PIECE(^PSX(552.3,0),"^",3)=NEW
LOCK -^PSX(552.3,0)
+1 if $DATA(^PSX(552.3,NEW,0))
GOTO F1
F2 LOCK +^PSX(552.3,NEW):3
if '$TEST
GOTO F2
SET ^PSX(552.3,NEW,0)=$EXTRACT(PSXACK,7,$LENGTH(PSXACK)-2)
SET ^PSX(552.3,NEW,1)=2
SET ^PSX(552.3,"AQ",NEW)=""
LOCK -^PSX(552.3,NEW)
SET XDA=$GET(XDA)_"^"_NEW
KILL NEW
+1 SET BLKA=BLK
+2 QUIT
QRY1 KILL LOG
SET LOG(1)="QRY1 QRY message never received for query #"_PSXQRYID
QUIT
QRY2 KILL LOG
SET LOG(1)="QRY2 EOT received with no terminator while waiting for QRY message"
QUIT
QRY3 KILL LOG
SET LOG(1)="QRY3 EOT received while waiting for QRY message"
QUIT
QRY5 ;K LOG S LOG(1)="QRY5 Unexpected character received: "_$S(X>31:$C(X),1:"")_" ("_X_") while waiting for QRY message" Q
+1 KILL LOG
SET LOG(1)="QRY5 Unexpected character received: "_X_"^"_$GET(QF)
QUIT
QRY6 KILL LOG
SET LOG(1)="QRY6 Timeout Timer D reading QRY message"
QUIT
QRY7 KILL LOG
SET LOG(1)="QRY7 QRY message longer than 240 characters"
QUIT
QRY8 KILL LOG
SET LOG(1)="QRY8 QRY message did not end with ETX"
QUIT
QRY9 KILL LOG
SET LOG(1)="QRY9 QRY was null"
QUIT
QRY10 KILL LOG
SET LOG(1)="QRY10 Timeout reading QRY checksum"
QUIT
QRY11 KILL LOG
SET LOG(1)="QRY11 QRY checksum contained an invalid hex digit ("_X_")"
QUIT
QRY12 KILL LOG
SET LOG(1)="QRY12 QRY checksum does not match"
QUIT
QRY13 KILL LOG
SET LOG(1)="QRY13 Message #"_PSXQRYID_" was rejected by OMCS"
QUIT
QRY14 KILL LOG
SET LOG(1)="QRY14 ENQ received with no terminator"
QUIT
QRY15 KILL LOG
SET LOG(1)="QRY15 MSA message ID did not match PSXQRYID # expected"
QUIT
QRY16 KILL LOG
SET LOG(1)="QRY16 Block count greater than 7."
QUIT
QRY17 KILL LOG
SET LOG(1)="QRY17 Wrong Block count received."
QUIT
QRY18 KILL LOG
SET LOG(1)="QRY18 Maximum retries reached for receiving message."
QUIT
QRY19 KILL LOG
SET LOG(1)="QRY19 Maximum Rxs received, query terminated."
QUIT
QRY20 KILL LOG
SET LOG(1)="QRY20 No activity on line continuing to monitor."
QUIT
+1 QUIT