source: FOIAVistA/trunk/r/ACCOUNTS_RECEIVABLE-PRCA-PRY-RC/RCRCSRV.m@ 1724

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

initial load of FOIAVistA 6/30/08 version

File size: 5.4 KB
Line 
1RCRCSRV ;ALB/CMS - RC SERVER DRIVER ; 16-JUN-00
2V ;;4.5;Accounts Receivable;**61,87,63,147,159**;Mar 20, 1995
3 ;;Per VHA Directive 10-93-142, this routine should not be modified.
4SERVER ;RC RC SERV SERVER OPTION MAIN ENTRY POINT
5 ;INPUT : Mailman variables
6 ;OUTPUT : Sets the XTMP global for certain types of message
7 ; : Sets the task job in the background if appropriate
8 ; : Adds Confirmation or Error to AR Transmission File
9 ;
10 Q:$G(XMZ)="" Q:'$D(^XMB(3.9,XMZ))
11 S XMXX="S.RC RC SERV",XMCHAN=1
12 D SETSB^XMA1C ;Save message in postmaster server basket
13 N RCBDT,RCCMSG,RCDOM,RCEDT,RCJOB,RCSCE,RCSTA,RCTYP,RCVAR,RCSITE,RCXMY,RCXMZ,RCXTYP
14 S RCXMZ=XMZ,RCJOB=$J
15 D READ
16 D SEND
17 D TASK
18 S XMZ=RCXMZ,XMSER="S.RC RC SERV" D REMSBMSG^XMA1C
19 K XMCHAN,XMDUZ,XMDUN,XMFROM,XMREC,XMSER,XMXX,XMY,XMZ
20Q Q
21 ;
22READ ;READ TRANSMISSION CHK FIRST LINE PUT MESSAGE IN XTMP
23 N II,RCEND,RCNT,XMRG,XMER,X2
24 S RCNT=0,RCCMSG="",RCSITE=$$SITE^RCMSITE,RCDOM=$G(XMFROM)
25 F II=0:0 D Q:$G(RCCMSG)]""
26 .X XMREC S RCNT=RCNT+1
27 .I $G(XMER)<0 D Q
28 ..I $G(RCEND)="" S RCCMSG="E;Incomplete message from Regional Counsel"
29 ..E S RCCMSG="C;AR accepted "_RCNT_" lines successfully."
30 ..S RCBDT=$P($G(RCEND),"$",4),RCEDT=$P($G(RCEND),"$",5)
31 ..; I +$P(RCVAR,U,5),$D(^XTMP(RCXTYP,RCJOB,0)) S $P(^XTMP(RCXTYP,RCJOB,0),"^",5)=RCNT
32 .I RCNT=1 D CHK1 I $G(RCCMSG)]"" Q
33 .I ($P(XMRG,"$",2)="END")!($P(XMRG,"$",3)="END") S RCEND=XMRG S RCNT=RCNT-1 Q
34 .I '$L(XMRG) S RCNT=RCNT-1 Q
35 .I +$P(RCVAR,U,5) S ^XTMP(RCXTYP,RCXMZ,RCNT)=XMRG
36 Q
37 ;
38SEND ;CONFIRMATION, ERROR, ORIGINAL MESSAGE TRANSPORT
39 ;I message is the original send confirmation or error to RC
40 ;INPUT: RCCMSG from Read module always set
41 ; RCVAR if exists
42 ;I message is a Confirmation or Error from RC to site quit
43 I $P(RCCMSG,";",1)="Q" G SENDQ
44 S RETRY=0
45 ;
46XMB N LN,RCCOM,RCSUB,RCWHO,RETRY,XMDUZ,XMSUB,XMTEXT,XMY,X,Y
47 ;Line below may not be needed
48 ;I confirmation don't send to anyone.
49 I $G(RCDOM)="" S RCDOM=$$RCDOM^RCRCUTL
50 S:$G(XMFROM)]"" XMY(XMFROM)=""
51 ;S RCWHO="S.RC RC SERV@"_RCDOM,XMY(RCWHO)=""
52 S RCWHO=RCDOM,XMY(RCWHO)=""
53 S Y=DT D D^DIQ
54 S LN(1)="$$RC$"_$G(RCTYP,"UNK")_"$"_$E(RCCMSG,1)_"$"_$G(RCSITE,"UNK")_"$"
55 S LN(2)="Status: Mail Message #("_XMZ_") received at the VAMC "_$G(RCSITE,"UNK")_" system on "_Y
56 S LN(3)=$S($E(RCCMSG,1)="E":"Error ",1:"")_"Message: "_$P(RCCMSG,";",2)
57 S LN(4)="Desc.: "_$P($G(RCVAR),U,4)
58 S (RCSUB,XMSUB)="AR/RC - "_$G(RCSITE,"UNK")_" "_$S($E(RCCMSG,1)="C":"CONFIRMATION ("_$G(RCTYP,"UNK")_")",1:"TRANSMISSION ("_$G(RCTYP,"UNK")_") ERROR")_" MESSAGE"
59 S XMTEXT="LN(",XMDUZ="ACCOUNTS RECEIVABLE RC SERVER"
60 D ^XMD I XMZ<1 S RETRY=RETRY+1 I RETRY<100 G XMB
61 S RCCOM=LN(3)
62 D ENT^RCRCXMS(XMZ,RCSUB,RCWHO,RCCOM)
63SENDQ Q
64 ;
65CHK1 ;CHECK FIRST LINE OF TRANSMISSION
66 ;First Line Syntax:
67 ;$$RC$S1$$sta#prefix$RC Address
68 ; o first four characters must be $$RC$
69 ; o $ piece 4 required must be a server code in routine RCRCVAR
70 ; o $ piece 5 will be "C" for a confirmation message or
71 ; "E" for error receiving the message
72 ; "" for the original transmission of a message
73 ; o $ piece 6 station number
74 ; o $ piece 7 is the RC address to send back to at RCDOM
75 ;Last Line Syntax: $END$#oflines$
76 ; $END$#oflines$Beg.Ref.DT$End.Ref.DT (Rec Rept. 4 of 4)
77 ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
78 ;INPUT: XMRG - First line of mail message
79 ;OUTPUT: RCVAR - Server Code^(C,E,O)^Recipient^desc.^0or1^taskroutine
80 ; or Killed
81 ; RCCMSG - Error message
82 ; RCSTA - Station Number
83 ; RCXMY - send message to
84 ; RCJOB - $J
85 ;
86 I $E(XMRG,1,5)'="$$RC$" S RCCMSG="E;RC Server at site is unable to interpret the first line of this message." G CHK1Q
87 S RCSCE=$P(XMRG,"$",5) S RCSCE=$S(RCSCE="C":RCSCE,RCSCE="E":RCSCE,RCSCE="":"O",1:"UNK")
88 S RCTYP=$P(XMRG,"$",4),RCVAR=$$CHK^RCRCVAR(RCTYP,RCSCE)
89 I $P(RCVAR,";",1)="E" S RCCMSG=RCVAR K RCVAR G CHK1Q
90 S RCSTA=$P(XMRG,"$",6)
91 S RCXMY=$P(XMRG,"$",7)
92 S RCDOM=$G(XMFROM)
93 ; If original message needs an XTMP global initialize it
94 I +$P(RCVAR,U,5) D XTMP(RCTYP,$P(RCVAR,U,4))
95 D FILE
96 I "CE"[RCSCE S RCCMSG="Q;"
97CHK1Q Q
98 ;
99TASK ;If message is original fire off the background job
100 ;fire off the background task now. (The time the server is run.)
101 I $G(RCSCE)="O",$E($G(RCCMSG),1)'="E" D TASK^RCRCRR
102TASKQ Q
103 ;
104FILE ;Update AR Transmission File
105 N DA,DIE,DR,RCCOM,RCX,X,Y
106 I RCSCE="O" D G FILEQ
107 . S RCSUB=$$SUBGET^XMGAPI0(RCXMZ)
108 . S RCCOM="RC sent Request Action ("_RCTYP_")."
109 . D ENT^RCRCXMS(RCXMZ,$G(RCSUB),"RC SERVER AT "_RCSTA,RCCOM)
110 ;If Message is a Confirm or Error from RC
111 X XMREC S RCNT=RCNT+1 I XMRG'["STATUS:" G FILEQ
112 S RCX=+$P(XMRG,"Message ",2)
113 S DA=$O(^RCT(349.3,"B",RCX,0))
114 I DA S DIE="^RCT(349.3,",DR=$S(RCSCE="E":6,1:5)_"////^S X="_RCXMZ D ^DIE
115 I 'DA,RCSCE="E" D
116 . S RCSUB=$$SUBGET^XMGAPI0(RCXMZ)
117 . S RCCOM="RC sent Error message ("_RCTYP_")."
118 . D ENT^RCRCXMS(RCXMZ,$G(RCSUB),"RC SERVER AT "_RCSTA,RCCOM)
119FILEQ Q
120 ;
121XTMP(RCTYP,RCDSC) ;INITIALIZE TOP XTMP Global for Server Type
122 ;INPUT : Type of server message must be passed
123 ;OUTPUT: XTMP global gets created for this server type
124 ; : RCXTYP gets set to PRCA_rctype(MR1,RR1,TR,CL...)
125 ; : RCJOB Job Number
126 ;XTMP purge data will be 30 days past the create date
127 N RCDT,X,X1,X2,Y,%,%H,%I
128 D NOW^%DTC S (X1,RCDT)=X,X2=30 D C^%DTC
129 S RCXTYP="PRCA"_RCTYP K ^XTMP(RCXTYP,RCXMZ)
130 S ^XTMP(RCXTYP,RCXMZ,0)=X_"^"_RCDT_"^"_RCDSC_U_RCXMZ
131 Q
132 ;RCRCSRV
Note: See TracBrowser for help on using the repository browser.