source: FOIAVistA/trunk/r/CMOP-PSX/PSXRSUS.m@ 1722

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

initial load of FOIAVistA 6/30/08 version

File size: 9.5 KB
Line 
1PSXRSUS ;BIR/WPB,BAB,HTW-CMOP Transmission Handler ;15 Dec 2001
2 ;;2.0;CMOP;**2,3,24,23,26,28,41,57,48**;11 Apr 97
3 ;Reference to ^PS(52.5 supported by DBIA #1978
4 ;Reference to ^PS(59 supported by DBIA #1976
5 ;Reference to routine DEV1^PSOSULB1 supported by DBIA #2478
6 ;
7 ;Select CMOP Rx data from File 52.5,build HL7 segments,
8 ;and transmit data
9 ; This routine is called from PSOSULB1 'Print from Suspense'
10 ;
11START I '$D(^XUSEC("PSXCMOPMGR",DUZ)) W !,"You are not authorized to use this option!" Q
12 I '$D(^XUSEC("PSX XMIT",DUZ)) W !,"You are not authorized to use this option!" Q
13 S (PSXFLAG,PSXTRANS)=0
14 L +^PSX(550.1):3 I '$T W !,"A lock on the RX QUEUE file was not obtainable. A transmission is in progress, try later." Q
15 ; lock on 550.1 obtainable, clear flags
16 I $D(^PSX(550,"TR","T")) F S PSXSYS=$O(^PSX(550,"TR","T",0)) Q:PSXSYS'>0 S PSXSTAT="H" D PSXSTAT^PSXRSYU
17 D SET^PSXSYS
18 S STATUS=$P($G(^PSX(550,+PSXSYS,0)),"^",3) I STATUS'="H" W !,STATUS," no Manual Transmission nor Print CMOP Suspense allowed at this time" G EXIT
19QRY W ! K DIR
20 S DIR(0)="NAO^1:5",DIR("A")="Select (1, 2, 3, 4, 5): "
21 S DIR("A",1)=" 1 - Initiate Standard CMOP Transmission"
22 S DIR("A",2)=" 2 - Initiate CS CMOP Transmission"
23 S DIR("A",3)=" 3 - Print Current Division - Standard CMOP from Suspense"
24 S DIR("A",4)=" 4 - Print Current Division - CS CMOP from Suspense"
25 S DIR("A",5)=" 5 - Standard Print from Suspense"
26 S DIR("A",6)=" "
27 S DIR("?")="Enter a number between 1 and 5.",DIR("??")="^D MSG1^PSXRHLP" D ^DIR I (Y<0)!($D(DIRUT)) K DIR G EXIT
28 W !!,DIR("A",X),!
29 S REPLY=X K Y,X
30 K DIRUT,DTOUT,DUOUT,DIROUT,DIR
31DIRECT ;Set PSXCS, PSXTRANS & PSXFLAG as per user choice
32 I REPLY="5" G DEV1^PSOSULB1
33 I "24"[REPLY S PSXCS=1
34 I "12"[REPLY S (PSXTRANS,PSXFLAG)=1
35 I "34"[REPLY S PSXFLAG=2
36 K REPLY
37 ;
38ASK ;Ask 'all divisions y/n' & date range for data transmission & checks for data
39 W !
40 ;ask all divisions y/n
41 I PSXFLAG=2 S PSXDIVML=0 G ASK2
42 K DIR S DIR(0)="Y",DIR("A")="Transmit Data for All Divisions ? ",DIR("B")="YES"
43 S DIR("?",1)="Yes - Transmit/Print All Divisions"
44 S DIR("?")="No - Transmit/Print One Division: "_$$GET1^DIQ(59,PSOSITE,.01)
45 D ^DIR K DIR
46 G:(Y<0)!($D(DIRUT)) EXIT
47 N PSXDIVML S PSXDIVML=+Y
48ASK2 W !
49 S %DT="AEX",%DT("A")=$S(PSXFLAG=1:"TRANSMIT CMOP DATA THRU DATE: ",PSXFLAG=2:"PRINT CMOP LABELS THRU DATE: ",1:0),%DT("B")="TODAY" D ^%DT K %DT,%DT("A"),%DT("B")
50 S:Y<0 PFLAG=1 G:Y<0 EXIT
51 S (PDT,PRTDT,TPRTDT)=Y K Y S Y=PDT X ^DD("DD") S PDT=Y K Y
52 S CHKDT=$O(^PS(52.5,"AQ","")) I CHKDT>PRTDT W !!,$S(PSXFLAG=1:"NOTHING THRU THIS DATE TO TRANSMIT.",PSXFLAG=2:"NOTHING THRU THIS DATE TO PRINT.",1:0) S PFLAG=1 G EXIT
53 I '$O(^PS(52.5,"AQ",0)) W !!,$S(PSXFLAG=1:"NOTHING THRU THIS DATE TO TRANSMIT.",PSXFLAG=2:"NOTHING THRU THIS DATE TO PRINT.",1:0) S PFLAG=1 G EXIT
54 ;
55 W ! K DIR S DIR(0)="Y",DIR("B")="NO",DIR("A")="Are you sure you wish to continue" D ^DIR K DIR S STOP=Y G:Y=0!($D(DIRUT))!($D(DUOUT)) EXIT K Y
56 S PSXSTAT="T" D PSXSTAT^PSXRSYU S PFLAG=0 I $G(PSXLOCK)>0 G EX1
57 ;
58DRIV ;calls the remaining routines to build the data for transmission and
59 S PSXDAYS=$P(PSOPAR,"^",27),X1=TPRTDT,X2=PSXDAYS D C^%DTC S PSXDTRG=X K X,X1,X2
60 S PSXVENDR=$S($P(^PSX(550,+$G(PSXSYS),0),"^")["HINE":"SI BAKER",$P(^PSX(550,+$G(PSXSYS),0),"^")["MURF":"SI BAKER",1:"ELECTROCOM")
61 ;set up queue device PSX or printer
62 I PSXFLAG=2 D BEGIN^PSXRPPL G:$G(POP) EXIT ;select printer PSLION
63QUE ; QUEUE the group/individual PSOSITE jobs for trans or the single job for print labels one division
64 S PSXDESC="CMOP "_$S($G(PSXCS)=1:"CS ",1:"NON-CS ")_"Transmission"
65 ;
66 S ZTDESC=$S(PSXFLAG=1:$G(PSXDESC),PSXFLAG=2:"Print CMOP Suspense",1:"")
67 S:PSXFLAG=1 ZTIO="",ZTRTN="TRANDIVS^PSXRSUS"
68 S:PSXFLAG=2 ZTIO=PSLION,ZTRTN="PRT^PSXRSUS"
69 ;
70 S PSXDUZ=DUZ,(PSOINST,PSXSITE)=+$P($G(PSXSYS),U,2)
71 S ZTDTH=$H
72 F X="PSXDIVML","PSOSITE","PSOLAP","PSOSYS","PSOPAR","PSXSYS","DUZ","PSXTRANS","PSXFLAG","PRTDT","PSOINST","PSXDUZ","PSXSITE","PSXVER" S ZTSAVE(X)=""
73 F X="PSXCS","PSXDAYS","PSXDTRG","PSOBARS","PSOBAR1","PSOBAR0","PSOPROP","PSXVENDR","PSLION","TPRTDT" S ZTSAVE(X)=""
74 ;
75 K ZTSK
76 D ^%ZTLOAD ;****TESTING switch to tasking vs foreground
77 W:$G(ZTSK) !,"Tasked ",ZTSK H 4
78 ;D @ZTRTN ;****TESTING run foreground, comment out above two lines
79 Q
80 ;
81TRANDIVS ;Entry from transmission tasking; loop all divisions / or process only 1
82 ;process/transmit all divisions
83LOCK ; >>>**** LOCK OF FILE 550.1 ****<<<
84 F I=1:1:3 L +^PSX(550.1):10 I $T S I=100
85 I I'=100 D CANMSG G EXIT ; could not get a lock in 18 minutes of waiting
86 D STOREVAR^PSXRSUS1 ; store critical variables
87 I $D(^PSX(550.2,"AQ")) D EN1^PSXRCVRY
88 I PSXDIVML N PSOSITE,PSOPAR D G EXIT
89 . S PSOSITE=0 F S PSOSITE=$O(^PS(59,PSOSITE)) Q:PSOSITE'>0 D
90 .. I '$D(^XTMP("PSXAUTOERR")) N $ETRAP,$ESTACK S $ETRAP="D TRAPERR^PSXRSUS"
91 .. D RESETVAR^PSXRSUS1 ;retrieve critical variables
92 .. S PSOPAR=^PS(59,PSOSITE,1),PRTDT=TPRTDT
93 .. S PSXDAYS=$P(PSOPAR,"^",27),X1=PRTDT,X2=PSXDAYS D C^%DTC S PSXDTRG=X K X,X1,X2 ;adjusts variables per divisional parameters.
94 .. D TRANS
95 ; process a single division
96 D
97 . I '$D(^XTMP("PSXAUTOERR")) N $ETRAP,$ESTACK S $ETRAP="D TRAPERR^PSXRSUS"
98 . D TRANS
99 G EXIT
100 ;
101 ;Called by Taskman to build CMOP PRINT data
102TRANS ;;Called by PSXAUTO Taskman to begin CMOP transmissions one division
103 S PSXZTSK=$G(ZTSK),PSXERFLG=0,PSXDUZ=DUZ
104 S PSXTST=0,PSXIN=$$GET1^DIQ(59,PSOSITE,2004,"I")
105 S:PSXIN'=""&(PSXIN<(DT+.1)) PSXTST=1
106 Q:PSXTST ;division inactivated
107 ;VMP OIFO BAY PINES;ELR;PSX*2*57 CK IF ALL NECESSARY ELEMENTS OF DIVISION ARE HERE
108 NEW PSXDIVER S PSXPRECK=1 D DIV^PSXBLD1 K PSXPRECK I $G(PSXDIVER) Q
109 S PSXSTAT="T" D PSXSTAT^PSXRSYU
110 I $G(PSXCS)=1 S X=$$FMADD^XLFDT(DT,+2) S ^XTMP("PSXCS"_PSOSITE,0)=X_U_DT_U_"CMOP CS TRANSMISSION"
111 D SDT^PSXRPPL I PSXERFLG=1 S PSXJOB=7 D ^PSXERR
112 I '$G(PSXBAT) D OERRCLR Q ;no RXs found nor loaded into 550.2
113RTR ;
114 ;Clear 550.1 of entries (INSURE NO MERGE) prior to transmission
115 K DIK,DA S DIK="^PSX(550.1,",DA=0 F S DA=$O(^PSX(550.1,DA)) Q:DA'>0 D ^DIK ;****TESTING
116 D EN^PSXBLD ; build entries into 550.1 by alpha patient
117 I PSXERFLG=1 S PFLAG=1 D EN^PSXERR
118 D EN^PSXRTR ;complete and send mailman message to CMOP
119 ;Clear 550.1 of entries (INSURE NO MERGE) after transmission complete
120 K DIK,DA S DIK="^PSX(550.1,",DA=0 F S DA=$O(^PSX(550.1,DA)) Q:DA'>0 D ^DIK ;****TESTING
121 D OERRCLR
122 Q
123PRT ; print from CMOP suspense
124 F I=1:1:3 L +^PSX(550.1):60 I $T S I=100
125 I I'=100 D CANMSG G EXIT ; could not get a lock in 3 minutes of waiting
126 ; set auto error trapping
127 D
128 . I '$D(^XTMP("PSXAUTOERR")) N $ETRAP,$ESTACK S $ETRAP="D PRTERR^PSXRPPL1"
129 . D PRT1
130 D OERRCLR
131 G EX1
132PRT1 S ZTREQ="@",PSXERFLG=0,NFLAG=2
133 D SDT^PSXRPPL
134 I $G(PSXBAT),$D(^PSX(550.2,PSXBAT,15)) D PRT^PSXRPPL
135 I PSXERFLG=1 S PSXJOB=7 D ^PSXERR
136 ;remove the batch from the transmission file as it was used only to hold the RXs for printing and not transmission
137 I $G(PSXBAT) K DIK,DA S DA=PSXBAT,DIK="^PSX(550.2," D ^DIK K DIK,DA ;****TESTING
138 G EX1
139EXIT ;
140 I $G(POP) S PSXSTAT="H" D PSXSTAT^PSXRSYU ;exit from 'no printer selected' of print labels CMOP
141 ;I $G(PFLAG)=1 S PSXSTAT="H" D PSXSTAT^PSXRSYU
142 K DA,DIE,DR
143 S DA=+PSXSYS,DIE="^PSX(550,",DR="9///@"
144 L +^PSX(550,DA):600 D ^DIE L -^PSX(550,DA)
145 K DA,DIE,DR
146 S PSXSTAT="H" D PSXSTAT^PSXRSYU
147EX1 K ^PSX("CMOP TRAN")
148 K CNAME,DFN,FILNUM,PNAME,PSXDAYS,PSXDTRG,^TMP($J,"PSX"),J,Y
149 K PSXPTR,REC,REF,REPLY,SDT,X,X1,X2,Y,ANSWER,PSXOK,RXNUM,PSXSITE,DIR,DIRUT,DTOUT,DUOUT,DIROUT,PSXCS,TXT,TEXT
150 K XDFN,STATUS,PSXSTAT,^TMP($J,"PSXDFN"),PDT,PSXDUZ,SITE,CHKDT,PSXERFLG,PSXRXERR,RXEX,FDATE,PSXJOB,PFLAG,PSXZTSK,PSXVENDR,ORSUB,ORST
151 L -^PSX(550.1)
152 Q
153OERRCLR ; clear any locks left in ^XTMP("OERR-"
154 S (ORST,ORSUB)="ORLK-"
155 F S ORSUB=$O(^XTMP(ORSUB)) Q:ORSUB'[ORST I ^XTMP(ORSUB,0)["CPRS/CMOP" K ^XTMP(ORSUB)
156 Q
157CANMSG ; lock on 550.1 not achieved send transmission/print cancelled message
158 S PSXCS=+$G(PSXCS)
159 S XMSUB=$S($G(PSXCS):"",1:"NON-")_"CS Manual Scheduled Transmission Canceled"
160 S:PSXFLAG=2 XMSUB="Print CMOP Suspense Cancelled."
161 S XMTEXT="TXT("
162 S TXT(1,0)="The "_$S($G(PSXCS):"",1:"NON-")_"CS Manual Transmission was cancelled"
163 S:PSXFLAG=2 TXT(1,0)="Print from CMOP Suspense was cancelled"
164 S TXT(2,0)="It could not obtain a lock on the RX QUEUE file. #550.1"
165 S TXT(3,0)="This indicates that a transmission was in progress."
166 S TXT(6,0)=" "
167 S TXT(7,0)="If you are getting this message frequently, please contact your IRM Group"
168 D GRP1^PSXNOTE
169 ;S XMY(DUZ)=""
170 D ^XMD
171 Q
172TRAPERR ; trap/process error
173 S XXERR=$$EC^%ZOSV
174 S PSXDIVNM=$$GET1^DIQ(59,PSOSITE,.01)
175 ;save an image of the transient file 550.1 for 2 days
176 D NOW^%DTC S DTTM=%
177 ;VMP OIFO BAY PINES;ELR;PSX*2*57 CHANGE PURGE DAYS TO T+12 FROM T+2
178 S X=$$FMADD^XLFDT(DT,+12) S ^XTMP("PSXERR "_DTTM,0)=X_U_DT_U_"CMOP "_XXERR
179 M ^XTMP("PSXERR "_DTTM,550.1)=^PSX(550.1)
180 S XMSUB="CMOP Error "_PSXDIVNM_" "_$$GET1^DIQ(550.2,+$G(PSXBAT),.01)
181 D GRP1^PSXNOTE
182 ;S XMY(DUZ)=""
183 S XMTEXT="TEXT("
184 S TEXT(1,0)=$S($G(PSXCS):"",1:"NON-")_"CS CMOP Transmission encountered the following error. Please investigate"
185 S TEXT(2,0)="Division: "_PSXDIVNM
186 S TEXT(3,0)="Type/Batch "_$S($G(PSXCS):"CS",1:"NON-CS")_" / "_$$GET1^DIQ(550.2,+$G(PSXBAT),.01)
187 S TEXT(4,0)="Error: "_XXERR
188 S TEXT(5,0)="The prescriptions have been reset and other divisions' transmissions are continuing."
189 S TEXT(6,0)="A copy of the file 550.1 can be found in ^XTMP(""PSXERR "_DTTM_""")"
190 D ^%ZTER
191 D ^XMD
192 ;I $E(IOST)="C" F XX=1:1:5 W !,TEXT(XX,0)
193 S PSXXDIV=PSOSITE
194 D EN1^PSXRCVRY ;hopefully no errors will be experienced in recovery
195 S PSOSITE=PSXXDIV
196 G UNWIND^%ZTER
197 Q
198STOPET ;disable auto error trapping
199 S ^XTMP("PSXAUTOERR",0)=DT_U_DT_U_"disable PSX CMOP auto error trapping for today"
200 Q
201STARTET ;enable auto error trapping
202 K ^XTMP("PSXAUTOERR",0)
203 Q
Note: See TracBrowser for help on using the repository browser.