source: WorldVistAEHR/trunk/r/OUTPATIENT_PHARMACY-PSO-APSP-HUIP/PSOBAIR2.m@ 949

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

initial load of WorldVistAEHR

File size: 6.1 KB
Line 
1PSOBAIR2 ;BIR/RTR-Report of suspended prescriptions with bad address ;08/16/2006
2 ;;7.0;OUTPATIENT PHARMACY;**233,200,264**;DEC 1997;Build 19
3 ;External reference ^PS(55 supported by DBIA 2228
4EN ;
5 N PSOAPAT,PSOSDT,PSOEDT,PSOSDTX,PSOEDTX,X,Y,X1,X2,PSUSDIV,PII,PSOCNT,PSOBDF
6 W !!,"This option shows unprinted suspended prescriptions for the following:",!
7 W !,"- BAD ADDRESS INDICATOR set in the PATIENT file (#2) and no active temporary",!," address"
8 W !,"- DO NOT MAIL set in the PHARMACY PATIENT file (#55)"
9 W !,"- FOREIGN ADDRESS set in the PATIENT file (#2) and no active US temporary",!," address",!
10 K DIR S DIR(0)="S^B:Bad Address Indicator;D:Do Not Mail;F:Foreign;A:All;",DIR("B")="A"
11 S DIR("A")="Print for Bad Address Indicator/Do Not Mail/Foreign/All (B/D/F/A)"
12 S DIR("?")="Print prescriptions with Bad Address Indicated/Do Not Mail/Foreign Address, or all"
13 D ^DIR K DIR I $D(DTOUT)!$D(DUOUT) D MESS Q
14 S PSOBDF=Y
15DATE ;
16 W ! S %DT="AEX",%DT("A")="Ending suspense date: " D ^%DT K %DT I Y<0!($D(DTOUT))!($D(DUOUT)) D MESS Q
17 S PSOEDT=Y D DD^%DT S PSOEDTX=Y
18 S X1=PSOEDT,X2=+1 D C^%DTC S PSOEDT=X
19 D:'$D(PSOPAR) ^PSOLSET I '$D(PSOPAR) D MESS Q
20 S PSOCNT=0 F PII=0:0 S PII=$O(^PS(59,PII)) Q:'PII S PSOCNT=PSOCNT+1
21 I PSOCNT=1 G SKIP
22 W !!?3,"You are logged in under the "_$P($G(^PS(59,+$G(PSOSITE),0)),"^")_" division.",!
23 K DIR S DIR(0)="Y",DIR("B")="Yes",DIR("A")="Print only those Rx's suspended for this division",DIR("?")="Enter 'Yes' to print only those Rx's for this division, enter 'No' to print Rx's suspended for all divisions."
24 D ^DIR K DIR I Y["^"!($D(DIRUT)) D MESS Q
25 S PSUSDIV=Y
26SKIP ;
27 K IOP,%ZIS,POP S %ZIS="QM" D ^%ZIS I $G(POP) D MESS Q
28 I $D(IO("Q")) D Q
29 .N GG
30 .S ZTRTN="REP^PSOBAIR2",ZTDESC="Pharmacy bad address suspense report" D
31 ..F GG="PSOSITE","PSOAPAT","PSOSDT","PSOEDT","PSOEDTX","PSOSDTX","PSUSDIV" S:$D(@GG) ZTSAVE(GG)=""
32 ..S ZTSAVE("PSOBDF*")="" D ^%ZTLOAD K %ZIS
33 .W !!,"Report queued to print.",!
34REP ;
35 K ^TMP("PSOBADL",$J) S (PSOBDF("B"),PSOBDF("D"),PSOBDF("F"))=0
36 N PSODEV,PSOUT,PSOLINE,PSOPAGE,PSOADND,PSOADF,PSOADFF,PSOAOPT,PSOAOPTA,PSOAOPTZ,PSOAOPTB,PSOAOPTC,PSOADLP,PSOANODE,PSOADX,SFN,PSOADATE,PSOC,PSOAALL,PSODFN,PSOANAME,PSONI,PSONX,PSONB,PSOASN,VA,DFN,PSONSSN,PSOAFLAG
37 U IO
38 S (PSOUT,PSOAFLAG)=0,PSODEV=$S($E(IOST,1,2)'="C-":0,1:1),PSOPAGE=1
39 S $P(PSOLINE,"-",78)=""
40ALL ;
41 N PSORD,SFN,PSOLBL,PSOX,PSODFN,RXIEN,PRINTED,RXSITE,RXSTS,PARTIAL
42 S PSODFN=0 F S PSODFN=$O(^PS(52.5,"AC",PSODFN)) Q:'PSODFN D
43 .S (PSOBAI,PSOBDF("B"),PSOBDF("D"),PSOBDF("F"))=0 D CHKADDR,FOREIGN,CHKMAIL Q:(PSOBDF("B")+PSOBDF("D")+PSOBDF("F"))=0
44 .Q:(PSOBDF="A"&'(PSOBDF("B")!PSOBDF("F")!PSOBDF("D"))) I PSOBDF'="A" Q:('PSOBDF(PSOBDF))
45 .S PSORD=0 F S PSORD=$O(^PS(52.5,"AC",PSODFN,PSORD)) Q:'PSORD!(PSORD>PSOEDT) D
46 ..S SFN=0 F S SFN=$O(^PS(52.5,"AC",PSODFN,PSORD,SFN)) Q:'SFN D DETAIL
47 S PSODFN=0 F S PSODFN=$O(^PS(52.5,"AG",PSODFN)) Q:'PSODFN D
48 .S (PSOBAI,PSOBDF("B"),PSOBDF("D"),PSOBDF("F"))=0 D CHKADDR,FOREIGN,CHKMAIL Q:(PSOBDF("B")+PSOBDF("D")+PSOBDF("F"))=0
49 .Q:(PSOBDF="A"&'(PSOBDF("B")!PSOBDF("F")!PSOBDF("D"))) I PSOBDF'="A" Q:('PSOBDF(PSOBDF))
50 .S SFN=0 F S SFN=$O(^PS(52.5,"AG",PSODFN,SFN)) Q:'SFN D
51 ..S PSORD=$G(^PS(52.5,SFN,0)),PSORD=$P(PSORD,"^",2) I PSORD<PSOEDT D DETAIL
52 D HD
53 I '$D(^TMP("PSOBADL",$J)) W !!,"No data found to print for this date range.",! G END
54 S PSONI="" F S PSONI=$O(^TMP("PSOBADL",$J,PSONI)) Q:PSONI=""!(PSOUT) D
55 .S PSONX="" F S PSONX=$O(^TMP("PSOBADL",$J,PSONI,PSONX)) Q:PSONX=""!(PSOUT) D NAME,PRALL D
56 ..S PSONB="" F S PSONB=$O(^TMP("PSOBADL",$J,PSONI,PSONX,PSONB)) Q:PSONB=""!(PSOUT) D
57 ...S SFN="" F S SFN=$O(^TMP("PSOBADL",$J,PSONI,PSONX,PSONB,SFN)) Q:SFN=""!(PSOUT) D
58 ....I ($Y+5)>IOSL D HD Q:PSOUT
59 ....S Y=PSONB D DD^%DT S PSOADATE=Y
60 ....S PNODE=$G(^TMP("PSOBADL",$J,PSONI,PSONX,PSONB,SFN)) D PRONE
61END ;
62 I PSOBDF="A" W !!!,"NOTE: B=BAD ADDRESS INDICATOR D=NO NOT MAIL F=FOREIGN ADDRESS"
63 K ^TMP("PSOBADL",$J)
64 K DTOUT,DUOUT,PSOBAI
65 I '$G(PSOUT),PSODEV W !!,"End of Report." K DIR S DIR(0)="E",DIR("A")="Press Return to continue" D ^DIR K DIR
66 I 'PSODEV W !!,"End of Report."
67 I PSODEV W !
68 E W @IOF
69 D ^%ZISC S:$D(ZTQUEUED) ZTREQ="@"
70 Q
71HD ;
72 S PSOAFLAG=1
73 I PSODEV,PSOPAGE'=1 W ! K DIR S DIR(0)="E",DIR("A")="Press Return to continue, '^' to exit" D ^DIR K DIR I 'Y S PSOUT=1 Q
74 I PSOPAGE=1,'PSODEV W ! I 1
75 E W @IOF
76 D W ?67,"PAGE: "_PSOPAGE S PSOPAGE=PSOPAGE+1
77 .W !,"Suspense "_$S(PSOBDF="A":"BAI/DO NOT MAIL/FOREIGN ADRESS",PSOBDF="B":"BAD ADDRESS INDICATOR",PSOBDF="D":"DO NOT MAIL",1:"FOREIGN ADDRESS")_" report - division = ",$S($G(PSUSDIV):$P($G(^PS(59,+$G(PSOSITE),0)),"^"),1:"ALL")
78 W !,"for suspense dates through "_$G(PSOEDTX) W:PSOBDF="A" ?70,"B/D/F"
79 W !,PSOLINE
80 Q
81MESS ;
82 W !!,"Nothing queued to print.",!
83 K DTOUT,DUOUT
84 Q
85NAME ;Set name(ssn)
86 K VA S DFN=PSONX D PID^VADPT6
87 S PSONSSN=$G(PSONI)_" ("_$E(VA("PID"),5,12)_")"
88 K VA
89 Q
90PRALL ;Print data for all patients
91 N PSOADDR
92 S PSOADDR=""
93 S PSOAFLAG=0
94 W !!,$G(PSONSSN) D CHKADDR W ?30," ",PSOADDR I ($Y+5)>IOSL D HD Q:PSOUT
95 Q
96PRONE ;Print data for one patient
97 N SFN0
98 S SFN0=$G(^PSRX(SFN,0)) I SFN0=""!($P(SFN0,"^",6)="") Q
99 D CON W !,$G(PSOADATE),?15," Rx#: ",$P(SFN0,"^"),?30," ",$P($G(^PSDRUG($P(SFN0,"^",6),0)),"^")
100 W:PSOBDF="A" ?70,PNODE
101 I ($Y+5)>IOSL D HD Q:PSOUT
102 Q
103CON ;
104 I PSOAFLAG W !,$G(PSONSSN) S PSOAFLAG=0
105 Q
106 ;
107CHKADDR ;
108 N PSOBADR,PSOTEMP
109 S PSOBADR=$$BADADR^DGUTL3(PSODFN)
110 I PSOBADR D
111 .S PSOTEMP=$$CHKTEMP^PSOBAI(PSODFN)
112 I PSOBADR,'PSOTEMP S (PSOBAI,PSOBDF("B"))=1 Q
113 Q
114 ;
115FOREIGN ;
116 N PSOFORGN
117 S DFN=PSODFN D ADD^VADPT
118 S PSOFORGN=$P($G(VAPA(25)),"^",2) I PSOFORGN'="",PSOFORGN'["UNITED STATES" S PSOBDF("F")=1
119 Q
120 ;
121CHKMAIL ;
122 N PSOTEMP,MAILEXP
123 S PSOTEMP=$G(^PS(55,PSODFN,0)) Q:$P(PSOTEMP,"^",3)'=2
124 S MAILEXP=$P(PSOTEMP,"^",5) I MAILEXP=""!(MAILEXP>DT) S PSOBDF("D")=1
125 Q
126 ;
127DETAIL ;
128 I '$D(^PS(52.5,SFN,0))!'$D(^DPT(+PSODFN,0)) Q
129 S RXIEN=+$$GET1^DIQ(52.5,SFN,.01,"I")
130 S RXSITE=+$$GET1^DIQ(52.5,SFN,.06,"I")
131 I $G(PSUSDIV),RXSITE'=$G(PSOSITE) Q
132 S RXSTS=$$GET1^DIQ(52,RXIEN,100,"I") I RXSTS>8 Q
133 S PARTIAL=+$$GET1^DIQ(52.5,SFN,.05,"I")
134 I PARTIAL,'$D(^PSRX(RXIEN,"P",PARTIAL)) Q
135 S PSOANAME=$P($G(^DPT(PSODFN,0)),"^") Q:PSOANAME=""
136 S ^TMP("PSOBADL",$J,PSOANAME,PSODFN,PSORD,RXIEN)=$S(PSOBDF("B"):"B",PSOBDF("D"):"D",PSOBDF("F"):"F",1:"")
137 Q
Note: See TracBrowser for help on using the repository browser.