source: WorldVistAEHR/trunk/r/OUTPATIENT_PHARMACY-PSO-APSP-HUIP/PSOBAIRP.m@ 1211

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

initial load of WorldVistAEHR

File size: 4.6 KB
RevLine 
[613]1PSOBAIRP ;BIR/RTR-Report of prescription mail labels with bad address ;08/16/2006
2 ;;7.0;OUTPATIENT PHARMACY;**233**;DEC 1997;Build 8
3 ;
4EN ;
5 N PSOFORM,PSOAPAT,PSOSDT,PSOEDT,PSOSDTX,PSOEDTX,X,Y,X1,X2
6 W !!,"This option provides a report that shows patients and prescriptions whose last"
7 W !,"label activity had a routing of mail and no valid permanent or temporary"
8 W !,"address. It will also indicate whether the patient now has a good address.",!!
9 K DIR S DIR(0)="SB^S:Single;A:All",DIR("A")="Print report for a Single patient, or All patients",DIR("B")="Single",DIR("?")=" ",DIR("?",1)="Enter 'S' to print address changes for one patient over the selected"
10 S DIR("?",2)="date range, enter 'A' to print address changes for all patients",DIR("?",3)="over the selected date range."
11 D ^DIR K DIR I Y["^"!($D(DTOUT))!($D(DUOUT)) D MESS Q
12 S PSOFORM=$S(Y="S":1,1:0)
13 I 'PSOFORM G DATE
14 K DIC W ! S DIC="^DPT(",DIC(0)="QEAM",DIC("A")="Select PATIENT: " D ^DIC K DIC I Y<1!($D(DUOUT))!($D(DTOUT)) D MESS Q
15 S PSOAPAT=+Y
16DATE ;
17 W !!
18 W ! K %DT S %DT="AEX",%DT("A")="Start fill date: " D ^%DT K %DT I Y<0!($D(DTOUT))!($D(DUOUT)) D MESS Q
19 S (%DT(0),PSOSDT)=Y D DD^%DT S PSOSDTX=Y
20 W ! S %DT="AEX",%DT("A")="End fill date: " D ^%DT K %DT I Y<0!($D(DTOUT))!($D(DUOUT)) D MESS Q
21 S PSOEDT=Y D DD^%DT S PSOEDTX=Y
22 S X1=PSOSDT,X2=-1 D C^%DTC S PSOSDT=X_".9999"
23 S X1=PSOEDT,X2=+1 D C^%DTC S PSOEDT=X
24 K IOP,%ZIS,POP S %ZIS="QM" D ^%ZIS I $G(POP) D MESS Q
25 I $D(IO("Q")) D Q
26 .S ZTRTN="REP^PSOBAIRP",ZTDESC="Pharmacy bad address mail label report",ZTSAVE("PSOFORM")="",ZTSAVE("PSOAPAT")="",ZTSAVE("PSOSDT")="",ZTSAVE("PSOEDT")="",ZTSAVE("PSOEDTX")="",ZTSAVE("PSOSDTX")="" D ^%ZTLOAD K %ZIS
27 .W !!,"Report queued to print.",!
28REP ;
29 K ^TMP("PSOBADL",$J)
30 N PSODEV,PSOUT,PSOLINE,PSOPAGE,PSOADND,PSOADF,PSOADFF,PSOAOPT,PSOAOPTA,PSOAOPTZ,PSOAOPTB,PSOAOPTC,PSOADLP,PSOANODE,PSOADX,PSORX,PSOADATE,PSOC,PSOAALL,PSOADFN,PSOANAME,PSONI,PSONX,PSONB,PSOASN,VA,DFN,PSONSSN,PSOAFLAG
31 U IO
32 S (PSOUT,PSOAFLAG)=0,PSODEV=$S($E(IOST,1,2)'="C-":0,1:1),PSOPAGE=1
33 S $P(PSOLINE,"-",78)=""
34ALL ;Print report for all patients
35 N PSORD,PSORX,PSOLBL,PSOX
36 S PSORD=PSOSDT F S PSORD=$O(^PSRX("AD",PSORD)) Q:'PSORD!(PSORD>PSOEDT) D
37 .S PSORX=0 F S PSORX=$O(^PSRX("AD",PSORD,PSORX)) Q:'PSORX D
38 ..S PSOLBL=$O(^PSRX(PSORX,"L",999999),-1) I 'PSOLBL Q
39 ..S PSOX=$G(^PSRX(PSORX,"L",PSOLBL,0)) I PSOX["(BAD ADDRESS",PSOX'["WINDOW" D
40 ...S PSOADFN=$P($G(^PSRX(PSORX,0)),"^",2) Q:'PSOADFN
41 ...I $G(PSOFORM),PSOADFN'=PSOAPAT Q
42 ...S PSOANAME=$P($G(^DPT(PSOADFN,0)),"^") Q:PSOANAME=""
43 ...S ^TMP("PSOBADL",$J,PSOANAME,PSOADFN,PSORD,PSORX)=""
44 D HD
45 I '$D(^TMP("PSOBADL",$J)) W !!,"No data found to print for this date range.",! G END
46 S PSONI="" F S PSONI=$O(^TMP("PSOBADL",$J,PSONI)) Q:PSONI=""!(PSOUT) D
47 .S PSONX="" F S PSONX=$O(^TMP("PSOBADL",$J,PSONI,PSONX)) Q:PSONX=""!(PSOUT) D NAME,PRALL D
48 ..S PSONB="" F S PSONB=$O(^TMP("PSOBADL",$J,PSONI,PSONX,PSONB)) Q:PSONB=""!(PSOUT) D
49 ...S PSORX="" F S PSORX=$O(^TMP("PSOBADL",$J,PSONI,PSONX,PSONB,PSORX)) Q:PSORX=""!(PSOUT) D
50 ....I ($Y+5)>IOSL D HD Q:PSOUT
51 ....S Y=PSONB D DD^%DT S PSOADATE=Y
52 ....D PRONE
53END ;
54 K ^TMP("PSOBADL",$J)
55 K DTOUT,DUOUT
56 I '$G(PSOUT),PSODEV W !!,"End of Report." K DIR S DIR(0)="E",DIR("A")="Press Return to continue" D ^DIR K DIR
57 I 'PSODEV W !!,"End of Report."
58 I PSODEV W !
59 E W @IOF
60 D ^%ZISC S:$D(ZTQUEUED) ZTREQ="@"
61 Q
62HD ;
63 I '$G(PSOFORM) S PSOAFLAG=1
64 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
65 I PSOPAGE=1,'PSODEV W ! I 1
66 E W @IOF
67 D W ?67,"PAGE: "_PSOPAGE S PSOPAGE=PSOPAGE+1
68 .I PSOFORM W !,"Bad address mail label report for "_$G(PSOANAME) Q
69 .W !,"Bad address mail label report for ALL Patients"
70 W !,"for fill date between "_$G(PSOSDTX)_" and "_$G(PSOEDTX)
71 W !,PSOLINE
72 Q
73MESS ;
74 W !!,"Nothing queued to print.",!
75 Q
76NAME ;Set name(ssn)
77 K VA S DFN=PSONX D PID^VADPT6
78 S PSONSSN=$G(PSONI)_" ("_$E(VA("PID"),5,12)_")"
79 K VA
80 Q
81PRALL ;Print data for all patients
82 N PSOADDR
83 S PSOADDR=""
84 S PSOAFLAG=0
85 W !!,$G(PSONSSN) D CHKADDR W ?30," ",PSOADDR I ($Y+5)>IOSL D HD Q:PSOUT
86 Q
87PRONE ;Print data for one patient
88 N PSORX0
89 S PSORX0=$G(^PSRX(PSORX,0)) I PSORX0=""!($P(PSORX0,"^",6)="") Q
90 D CON W !,$G(PSOADATE),?15," Rx#: ",$P(PSORX0,"^"),?30," ",$P($G(^PSDRUG($P(PSORX0,"^",6),0)),"^")
91 I ($Y+5)>IOSL D HD Q:PSOUT
92 Q
93CON ;
94 I PSOAFLAG,'PSOFORM W !,$G(PSONSSN) S PSOAFLAG=0
95 Q
96 ;
97CHKADDR ;
98 N PSOBADR,PSOTEMP
99 I $G(PSONX)="" Q
100 S PSOBADR=$$BADADR^DGUTL3(PSONX)
101 I PSOBADR D
102 .S PSOTEMP=$$CHKTEMP^PSOBAI(PSONX)
103 I PSOBADR,'PSOTEMP S PSOADDR="** BAD ADDRESS **" Q
104 S PSOADDR="PATIENT NOW HAS A VALID ADDRESS"
105 Q
Note: See TracBrowser for help on using the repository browser.