source: FOIAVistA/tag/r/CMOP-PSX/PSXACK.m@ 1068

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

initial load of FOIAVistA 6/30/08 version

File size: 3.5 KB
Line 
1PSXACK ;BIR/BAB-Process MSA Segment after Msg Transmits ; [ 04/08/97 2:06 PM ]
2 ;;2.0;CMOP;;11 Apr 97
3EN ;This routine processes an MSA segment and returns PSXPOP=1
4 ;if there was a problem.
5 ;Requires PSXQN = message entry number
6SLAVE ;wait to enter slave mode to receive ACK message
7 R *X:PSXDLTD E D
8 E D ACK1 G ERROR
9 I X'=ENQ D ACK5 G ERROR
10 R *X:PSXDLTA
11 I ('$T)!(X'=TERM) D ACK4 G ERROR
12 W *ACK,0,*TERM
13 S BFLAG=0
14 S BHST=0
15MSG R *X:PSXDLTD E D ACK1 G ERROR
16 I X=STX G READ
17 I X=EOT R *X:PSXDLTA I X=TERM G TST
18 D ACK5 ;unexpected character received
19ERROR D FLUSH1^PSXUTL
20 D LOG^PSXUTL
21 S PSXPOP=1
22 K PSXHEX,PSXACK,PSXREJ,LOG,PSXSUM
23 QUIT
24READ S PSXACK=""
25 S PSXTMD=$P($H,",",2)
26GETMSG S AA=0 F %=1:1 D Q:'%
27 .R *X:PSXDLTA E D ACK6,LOG^PSXUTL S %=0,X="" Q
28 .D CHKD^PSXUTL I PSXTMOUT D ACK6,LOG^PSXUTL S %=0,X="" Q
29 .I %>240 D ACK7,LOG^PSXUTL S %=0,X="" Q
30 .S PSXACK=PSXACK_$C(X)
31 .I (X=ETX)!(X=ETB) S %=0
32 I X=ETX S AA=1 G TEST
33 I X=ETB S AA=2 G TEST
34 I X=EOT R *X:PSXDLTA G:X=TERM TST
35 I (X'=ETX)!(X'=ETB)!(X'=EOT) D ACK8 G ERROR
36 I PSXACK="" D ACK9 G ERROR
37 Q
38TEST R *X:PSXDLTA E D ACK10 G ERROR
39 I "0123456789ABCDEF"'[$C(X) D ACK11 G ERROR
40 S PSXSUM=$C(X)
41CHKSUM R *X:PSXDLTA E D ACK10 G ERROR
42 I "0123456789ABCDEF"'[$C(X) D ACK11 G ERROR
43 S PSXSUM=PSXSUM_$C(X)
44 S X=PSXACK X ^%ZOSF("LPC") S PSXHEX=Y D HEX^PSXUTL
45 R *X:1 I X'=TERM D ACK5
46 I PSXHEX'=PSXSUM D ACK12 G ERROR
47 I PSXHEX=PSXSUM D FLUSH1^PSXUTL
48 ;S:$P(PSXACK,"|",1)["BHS" BHST=1,BFLAG=1,PSXBHS=1
49 S:$P(PSXACK,"|",1)["BHS" BHST=1,BFLAG=1
50 I (BFLAG=1)&($P(PSXACK,"|",1)["BHS") S PSXMSH=$G(PSXMSH)_"+"_$E(PSXACK,7,$L(PSXACK)-2)
51 I (BFLAG=1)&($P(PSXACK,"|",1)["MSA") S PSXMSA=$G(PSXMSA)_"+"_$E(PSXACK,7,$L(PSXACK)-2),BFLAG=0,PSXBHS=1 S:$G(PSXMSA)["|AR|" PSXBHS=0 K:$G(PSXBHS)'>0 PSXMSH,PSXMSA
52 I $E(PSXACK,7,10)["MSH|" S TACK=$E(PSXACK,7,$L(PSXACK)-2)
53 W *ACK,$S(AA=1:2,AA=2:1,1:""),*TERM D:$P(PSXACK,"|",1)["MSA" FILE G MSG
54 Q
55FILE Q:$G(BHST)=1
56 I $P($P(PSXACK,"MSA",2),"|",3)'=PSXMSGID D ACK15 G ERROR
57 S XXX=$P($P(PSXACK,"MSA",2),"|",3),REC=$O(^PSX(552.2,"B",XXX,""))
58 S REC=$G(PSXQN)
59 Q:$G(REC)=""
60 S ^PSX(552.2,REC,"ACK")=TACK_$E(PSXACK,7,$L(PSXACK)-2)
61 S (PSXPOP,PSXREJ)=0
62 I (PSXACK["AR") S PSXREJ=1 D ACK13,LOG^PSXUTL
63 L +^PSX(552.2,REC):DTIME I $T S DIE="^PSX(552.2,",DA=REC,DR="1///"_$S(PSXREJ:99,'PSXREJ:3,1:0)_";3///^S X=$H" D ^DIE K DIE,DA L -^PSX(552.2,REC)
64 K XXX,REC,PSXREJ,PSXACK,TACK
65 Q
66TST D FLUSH1^PSXUTL
67 K PSXHEX,PSXACK,PSXREJ,LOG,PSXSUM
68 Q
69ACK1 K LOG S LOG(1)="ACK1 ACK message never received for order #"_$P($G(^PSX(552.2,PSXQN,0)),"^",1) Q
70ACK2 K LOG S LOG(1)="ACK2 EOT received with no terminator while waiting for ACK message" Q
71ACK3 K LOG S LOG(1)="ACK3 EOT received while waiting for ACK message" Q
72ACK4 K LOG S LOG(1)="ACK4 ENQ received with no terminator while waiting for ACK message" Q
73ACK5 K LOG S LOG(1)="ACK5 Unexpected character received: "_$S(X>31:$C(X),1:"")_" ("_X_") while waiting for ACK message" Q
74ACK6 K LOG S LOG(1)="ACK6 Timeout Timer D reading ACK message" Q
75ACK7 K LOG S LOG(1)="ACK7 ACK message longer than 240 characters" Q
76ACK8 K LOG S LOG(1)="ACK8 ACK message did not end with ETX" Q
77ACK9 K LOG S LOG(1)="ACK9 ACK was null" Q
78ACK10 K LOG S LOG(1)="ACK10 Timeout reading ACK checksum" Q
79ACK11 K LOG S LOG(1)="ACK11 ACK checksum contained an invalid hex digit ("_X_")" Q
80ACK12 K LOG S LOG(1)="ACK12 ACK checksum does not match" Q
81ACK13 K LOG S LOG(1)="ACK13 Order #"_$P($G(^PSX(552.2,PSXQN,0)),"^",1)_" was rejected by CMOP" Q
82ACK14 K LOG S LOG(1)="ACK14 ENQ received with no terminator" Q
83ACK15 K LOG S LOG(1)="ACK15 MSA order # did not match "_$P($G(^PSX(552.2,PSXQN,0)),"^",1)_" # expected" Q
Note: See TracBrowser for help on using the repository browser.