source: FOIAVistA/tag/r/CMOP-PSX/PSXQRY.m@ 1424

Last change on this file since 1424 was 628, checked in by George Lilly, 15 years ago

initial load of FOIAVistA 6/30/08 version

File size: 6.5 KB
Line 
1PSXQRY ;BIR/WPB,BAB-Sends/Receives the Query ;[ 10/23/97 6:59 AM ]
2 ;;2.0;CMOP;**9**;11 Apr 97
3EN D NOW^%DTC S XZ=$P(^PSX(553.1,0),"^",3),INT=$P(^PSX(553,1,0),"^",9) S:$G(INT)'>0 INT=1
4 I $G(XZ) S LQRYTM=$P(^PSX(553.1,XZ,0),"^",2) I %'>$$FMADD^XLFDT(LQRYTM,0,$G(INT),0,0) G ^PSXJOB
5 S (PSXCNT,PSXTRYN,RXCNT)=0,QLR=$P($G(^PSX(553,1,0)),"^",8)
6 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
7F D FILE^DICN S PSXQRYID=+Y,LOG(1)="QUERY # "_PSXQRYID_" initiated."_$G(PSXQRYA) D LOG^PSXUTL
8 K DA,DIC,DUOUT,DTOUT,DLAYGO,X,Y,%,DINUM,PSXPOP,TRY
9 S PSXQRY=1 D BID^PSXMST G:$G(PSXQUIT) TST
10 D TSOUT^PSXUTL
11 S PSXBLK=1,PSXLAST=0
12 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
13 S PSXBLK=2,PSXLAST=1 S PSXTXT="QRD|"_PSXTS_"|R|I|"_PSXQRYID_"|||"_QLR_"^ZO|OP|OTH|ALL" D XMIT^PSXSND G:$G(PSXPOP) TST
14 W *EOT,*TERM
15 D SLAVE
16TST D FLUSH1^PSXUTL
17 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
18 S $P(^PSX(554,1,0),"^",3)=PSXQRYID
19 S:$G(PSXQRYA) ^PSX(553,1,"S")="S"
20 K PSXHEX,PSXACK,LOG,BLK,BLKA,PSXQRYID,PSXTXT,PSXBLK,%,X,Y,PSXLAST,QLR,MESSID,MSGID,RXCNT,PSXQRY,PSXQRYA,PSXSTOP,PSXPOP,PSXQUIT
21 G ^PSXJOB
22NAK D FLUSH1^PSXUTL,LOG^PSXUTL
23 W *NAK,*TERM
24 S PSXTRYN=PSXTRYN+1 G:PSXTRYN>5 ERROR G MSG
25ND I $G(^PSX(553,1,"S"))="S" S PSXSTOP=1 Q
26 D QRY20,FLUSH1^PSXUTL,LOG^PSXUTL S PSXTRYN=PSXTRYN+1 G:PSXTRYN>5 ERROR G MSG
27RTN G:PSXCNT'>1 SLAVE
28 Q:$G(PSXQRY)=0
29 D BID^PSXMST G:$G(PSXQUIT) TST D TSOUT^PSXUTL K PSXTXT,PSXLAST S PSXBLK=1,PSXLAST=0
30 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)
31 S PSXBLK=2,PSXLAST=1
32 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)
33 ;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
34 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
35 I $G(QRYFLG)>0 K DA,DIE,DR
36 W *EOT,*TERM
37 D NOW^%DTC
38 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)
39 K MESSID,MSGID,TRY,CANFLAG
40 I $G(^PSX(553,1,"S"))="S" S PSXSTOP=1 Q
41SLAVE S BLKA=0
42 R *X:PSXDLTD E D
43 E D QRY1,LOG^PSXUTL G ND
44 I X'=ENQ D QRY5 S TRY=$G(TRY)+1 G:$G(TRY)'>5 SLAVE G ERROR
45 R *X:PSXDLTA
46 I ('$T)!(X'=TERM) D QRY14 G ERROR
47 W *ACK,0,*TERM
48 R *X:PSXDLTD G:X=STX READ I X=EOT R *X:PSXDLTA Q:X=TERM
49MSG R *X:PSXDLTD E D QRY1,LOG^PSXUTL G ND
50 I X=STX G READ
51 I X=EOT R *X:PSXDLTA I X=TERM G RTN
52 S QF="STX/EOT"
53 D QRY5 ;unexpected character received
54ERROR D FLUSH1^PSXUTL,LOG^PSXUTL S QRYPOP=1
55 Q
56READ S PSXACK="" S PSXTMD=$P($H,",",2)
57GETMSG F %=1:1 D Q:'%
58 .R *X:PSXDLTA E D QRY6,LOG^PSXUTL S %=0,X="" Q
59 .D CHKD^PSXUTL I PSXTMOUT D QRY6,LOG^PSXUTL S %=0,X="" Q
60 .I %>240 D QRY7,LOG^PSXUTL S %=0,X="" Q
61 .S PSXACK=PSXACK_$C(X)
62 .I (X=ETX)!(X=ETB) S %=0
63 I X=ETX S PSXCNT=PSXCNT+1 G TEST
64 I X=ETB G TEST
65 I X=EOT R *X:PSXDLTA G:X=TERM MSG
66 I (X'=ETX)!(X'=ETB)!(X'=EOT) D QRY8 G NAK
67 I PSXACK="" D QRY9 G ERROR
68 Q
69TEST R *X:PSXDLTA E D QRY10 G ERROR
70 I "0123456789ABCDEF"'[$C(X) D QRY11 G NAK
71 S PSXSUM=$C(X)
72CHKSUM R *X:PSXDLTA E D QRY10 G ERROR
73 I "0123456789ABCDEF"'[$C(X) D QRY11 G NAK
74 S PSXSUM=PSXSUM_$C(X)
75 S X=PSXACK X ^%ZOSF("LPC") S PSXHEX=Y D HEX^PSXUTL
76 R *X:1 I X'=TERM D QRY5
77 I PSXHEX'=PSXSUM D QRY12 G NAK
78 I PSXHEX=PSXSUM D FLUSH1^PSXUTL
79 S BLK=$E(PSXACK,1) I BLK>7 D QRY16 G NAK
80 I RXCNT=QLR&($E(PSXACK,7,10)'["BTS") D QRY19,LOG^PSXUTL W *EOT,*TERM Q
81 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
82 I $E(PSXACK,7,9)["MSA"&($P(PSXACK,"|",3)'=PSXQRYID) D QRY15 G NAK
83 I $E(PSXACK,7,9)["QRD"&($P(PSXACK,"|",5)'=PSXQRYID) D QRY15 G NAK
84 W *ACK,BLK,*TERM D FILE G MSG
85 Q
86FILE I $E(PSXACK,7,10)["MSH|" S MESSID=$E(PSXACK,7,$L(PSXACK)-2),MSGID=$P(MESSID,"|",10),QRYFLG=0,XDA=""
87 I $E(PSXACK,7,12)["NTE|99" D
88 .S CANFLAG=0
89 .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
90 .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
91 .S RXCNT=RXCNT+1
92 I $E(PSXACK,7,13)["NTE|100" S:($G(CANFLAG)>0&($P($P(PSXACK,"\",1),"|",4)="")) QRYFLG=5
93 Q:BLK=BLKA
94 Q:$G(QRYFLG)>0
95F1 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)
96 G:$D(^PSX(552.3,NEW,0)) F1
97F2 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
98 S BLKA=BLK
99 Q
100QRY1 K LOG S LOG(1)="QRY1 QRY message never received for query #"_PSXQRYID Q
101QRY2 K LOG S LOG(1)="QRY2 EOT received with no terminator while waiting for QRY message" Q
102QRY3 K LOG S LOG(1)="QRY3 EOT received while waiting for QRY message" Q
103QRY5 ;K LOG S LOG(1)="QRY5 Unexpected character received: "_$S(X>31:$C(X),1:"")_" ("_X_") while waiting for QRY message" Q
104 K LOG S LOG(1)="QRY5 Unexpected character received: "_X_"^"_$G(QF) Q
105QRY6 K LOG S LOG(1)="QRY6 Timeout Timer D reading QRY message" Q
106QRY7 K LOG S LOG(1)="QRY7 QRY message longer than 240 characters" Q
107QRY8 K LOG S LOG(1)="QRY8 QRY message did not end with ETX" Q
108QRY9 K LOG S LOG(1)="QRY9 QRY was null" Q
109QRY10 K LOG S LOG(1)="QRY10 Timeout reading QRY checksum" Q
110QRY11 K LOG S LOG(1)="QRY11 QRY checksum contained an invalid hex digit ("_X_")" Q
111QRY12 K LOG S LOG(1)="QRY12 QRY checksum does not match" Q
112QRY13 K LOG S LOG(1)="QRY13 Message #"_PSXQRYID_" was rejected by OMCS" Q
113QRY14 K LOG S LOG(1)="QRY14 ENQ received with no terminator" Q
114QRY15 K LOG S LOG(1)="QRY15 MSA message ID did not match PSXQRYID # expected" Q
115QRY16 K LOG S LOG(1)="QRY16 Block count greater than 7." Q
116QRY17 K LOG S LOG(1)="QRY17 Wrong Block count received." Q
117QRY18 K LOG S LOG(1)="QRY18 Maximum retries reached for receiving message." Q
118QRY19 K LOG S LOG(1)="QRY19 Maximum Rxs received, query terminated." Q
119QRY20 K LOG S LOG(1)="QRY20 No activity on line continuing to monitor." Q
120 Q
Note: See TracBrowser for help on using the repository browser.