source: WorldVistAEHR/trunk/r/OUTPATIENT_PHARMACY-PSO-APSP-HUIP/PSOADDR.m@ 1742

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

initial load of WorldVistAEHR

File size: 8.2 KB
Line 
1PSOADDR ;BIR/RTR-Print address changes from Audit file ;10/17/01
2 ;;7.0;OUTPATIENT PHARMACY;**127,233**;DEC 1997;Build 8
3 ;External reference to ^DIA supported by DBIA 2602
4 ;
5EN ;
6 N PSOFORM,PSOAPAT,PSOSDT,PSOEDT,PSOSDTX,PSOEDTX,X,Y,X1,X2
7 W !!,"This option provides a report that displays changes made to permanent and"
8 W !,"temporary mailing address information in the PATIENT file (#2). Also changes"
9 W !,"to the MAIL field (#.03) and the MAIL STATUS EXPIRATION DATE field (#.05)"
10 W !,"in the PHARMACY PATIENT file (#55) will be displayed."
11 W !,"Changes can only be displayed if the edits were made using VA FileMan, and the"
12 W !,"Audit function was turned on for the field(s) at the time of the edit.",!!
13 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"
14 S DIR("?",2)="date range, enter 'A' to print address changes for all patients",DIR("?",3)="over the selected date range."
15 D ^DIR K DIR I Y["^"!($D(DTOUT))!($D(DUOUT)) D MESS Q
16 S PSOFORM=$S(Y="S":1,1:0)
17 I 'PSOFORM G DATE
18 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
19 S PSOAPAT=+Y
20DATE ;
21 W !!
22 I PSOFORM W !,"This report will be sorted by Date/time of edit."
23 I 'PSOFORM W !,"This report will be sorted by Patient Name, and within Patient Name will be",!,"sorted by Date/time of edit."
24 W !,"A beginning and ending date must now be entered for the search."
25 K DIR W ! S DIR(0)="DAO^:DT:APEX",DIR("A")="Beginning Date: ",DIR("?")=" ",DIR("?",1)="Enter the date to begin searching for changes to address fields.",DIR("?",2)="A future date cannot be entered." D ^DIR K DIR
26 I 'Y!($D(DTOUT))!($D(DUOUT)) D MESS Q
27 S PSOSDT=Y D DD^%DT S PSOSDTX=Y
28 S X1=PSOSDT,X2=-1 D C^%DTC S PSOSDT=X_".9999"
29 W ! K DIR S DIR(0)="DAO^"_PSOSDT_"::APEX",DIR("A")="Ending Date: ",DIR("?")=" ",DIR("?",1)="Enter the ending date of the search for changes to address fields.",DIR("?",2)="This date cannot be before the beginning date." D ^DIR K DIR
30 I 'Y!($D(DTOUT))!($D(DUOUT)) D MESS Q
31 S PSOEDT=Y D DD^%DT S PSOEDTX=Y
32 S X1=PSOEDT,X2=+1 D C^%DTC S PSOEDT=X
33 K IOP,%ZIS,POP S %ZIS="QM" D ^%ZIS I $G(POP) D MESS Q
34 I $D(IO("Q")) D Q
35 .S ZTRTN="REP^PSOADDR",ZTDESC="Pharmacy Address change report",ZTSAVE("PSOFORM")="",ZTSAVE("PSOAPAT")="",ZTSAVE("PSOSDT")="",ZTSAVE("PSOEDT")="",ZTSAVE("PSOEDTX")="",ZTSAVE("PSOSDTX")="" D ^%ZTLOAD K %ZIS W !!,"Report queued to print.",!
36REP ;
37 K ^TMP("PSOADD",$J)
38 N PSODEV,PSOUT,PSOLINE,PSOPAGE,PSOADND,PSOADUSR,PSOADF,PSOADFF,PSOAOPT,PSOAOPTA,PSOAOPTZ,PSOAOPTB,PSOAOPTC,PSOADLP,PSOANODE,PSOADX,PSOADXX,PSOADATE,PSOC,PSOAALL,PSOADFN,PSOANAME,PSONI,PSONX,PSONB,PSOASN,VA,DFN,PSONSSN,PSOAFLAG
39 U IO
40 S (PSOUT,PSOAFLAG)=0,PSODEV=$S($E(IOST,1,2)'="C-":0,1:1),PSOPAGE=1
41 S $P(PSOLINE,"-",78)=""
42 I $G(PSOFORM) G ONE
43ALL ;Print report for all patients
44 N PSOFILE
45 F PSOFILE=2,55 F PSOAALL=PSOSDT:0 S PSOAALL=$O(^DIA(PSOFILE,"C",PSOAALL)) Q:'PSOAALL!(PSOEDT'>PSOAALL) S PSOADLP="" F S PSOADLP=$O(^DIA(PSOFILE,"C",PSOAALL,PSOADLP)) Q:PSOADLP="" D
46 .S PSOADFN=$P($G(^DIA(PSOFILE,PSOADLP,0)),"^"),PSOC=$P($G(^(0)),"^",3) Q:'PSOADFN
47 .S PSOANAME=$P($G(^DPT(PSOADFN,0)),"^") Q:PSOANAME=""
48 .I PSOFILE=2 I PSOC=.111!(PSOC=.112)!(PSOC=.113)!(PSOC=.114)!(PSOC=.115)!(PSOC=.116)!(PSOC=.1211)!(PSOC=.1212)!(PSOC=.1213)!(PSOC=.1214)!(PSOC=.1215)!(PSOC=.1216)!(PSOC=.1112)!(PSOC=.12112)!(PSOC=.121)!(PSOC=.1217)!(PSOC=.1218)!(PSOC=.12105) D
49 ..S ^TMP("PSOADD",$J,PSOANAME,PSOADFN,PSOAALL,PSOFILE,PSOADLP)=$G(^DIA(2,PSOADLP,0))
50 .I PSOFILE=55 I PSOC=.03!(PSOC=.05) D
51 ..S ^TMP("PSOADD",$J,PSOANAME,PSOADFN,PSOAALL,PSOFILE,PSOADLP)=$G(^DIA(55,PSOADLP,0))
52 D HD
53 I '$D(^TMP("PSOADD",$J)) W !!,"No data found to print for this date range.",! G END
54 S PSONI="" F S PSONI=$O(^TMP("PSOADD",$J,PSONI)) Q:PSONI=""!(PSOUT) S PSONX="" F S PSONX=$O(^TMP("PSOADD",$J,PSONI,PSONX)) Q:PSONX=""!(PSOUT) D NAME S PSONB="" F S PSONB=$O(^TMP("PSOADD",$J,PSONI,PSONX,PSONB)) Q:PSONB=""!(PSOUT) D
55 .F PSOFILE=2,55 S PSOADXX="" F S PSOADXX=$O(^TMP("PSOADD",$J,PSONI,PSONX,PSONB,PSOFILE,PSOADXX)) Q:PSOADXX=""!(PSOUT) D
56 ..I ($Y+5)>IOSL D HD Q:PSOUT
57 ..S Y=PSONB D DD^%DT S PSOADATE=Y
58 ..S PSOADND=$G(^TMP("PSOADD",$J,PSONI,PSONX,PSONB,PSOFILE,PSOADXX))
59 ..D FLD
60 ..D PRALL
61 G END
62ONE ;Print report for one patient
63 N PSOFILE
64 F PSOFILE=2,55 S PSOADLP="" F S PSOADLP=$O(^DIA(PSOFILE,"B",PSOAPAT,PSOADLP)) Q:PSOADLP="" S PSOC=$P($G(^DIA(PSOFILE,PSOADLP,0)),"^",3) D
65 .S PSOANODE=$G(^DIA(PSOFILE,PSOADLP,0))
66 .I +$P($G(PSOANODE),"^",2)>PSOSDT,+$P($G(PSOANODE),"^",2)<PSOEDT D
67 ..I PSOFILE=2 I PSOC=.111!(PSOC=.112)!(PSOC=.113)!(PSOC=.114)!(PSOC=.115)!(PSOC=.116)!(PSOC=.1211)!(PSOC=.1212)!(PSOC=.1213)!(PSOC=.1214)!(PSOC=.1215)!(PSOC=.1216)!(PSOC=.1112)!(PSOC=.12112)!(PSOC=.121)!(PSOC=.1217)!(PSOC=.1218)!(PSOC=.12105) D
68 ...S ^TMP("PSOADD",$J,+$P(PSOANODE,"^",2),PSOFILE,PSOADLP)=PSOANODE
69 ..I PSOFILE=55 I PSOC=.03!(PSOC=.05) D
70 ...S ^TMP("PSOADD",$J,+$P(PSOANODE,"^",2),PSOFILE,PSOADLP)=PSOANODE
71 K VA S DFN=PSOAPAT D PID^VADPT6 S PSOASN=$P($G(^DPT(+$G(PSOAPAT),0)),"^")_" ("_$E(VA("PID"),5,12)_")"
72 K VA
73 D HD
74 I '$D(^TMP("PSOADD",$J)) W !!,"No data found to print for this date range.",! G END
75 S PSOADX="" F S PSOADX=$O(^TMP("PSOADD",$J,PSOADX)) Q:PSOADX=""!(PSOUT) F PSOFILE=2,55 S PSOADXX="" F S PSOADXX=$O(^TMP("PSOADD",$J,PSOADX,PSOFILE,PSOADXX)) Q:PSOADXX=""!(PSOUT) D
76 .I ($Y+5)>IOSL D HD Q:PSOUT
77 .S Y=PSOADX D DD^%DT S PSOADATE=Y
78 .S PSOADND=$G(^TMP("PSOADD",$J,PSOADX,PSOFILE,PSOADXX))
79 .D FLD
80 .W ! D PRONE
81END ;
82 K ^TMP("PSOADD",$J)
83 I '$G(PSOUT),PSODEV W !!,"End of Report." K DIR S DIR(0)="E",DIR("A")="Press Return to continue" D ^DIR K DIR
84 I 'PSODEV W !!,"End of Report."
85 I PSODEV W !
86 E W @IOF
87 D ^%ZISC S:$D(ZTQUEUED) ZTREQ="@"
88 Q
89HD ;
90 I '$G(PSOFORM) S PSOAFLAG=1
91 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
92 I PSOPAGE=1,'PSODEV W ! I 1
93 E W @IOF
94 D W ?67,"PAGE: "_PSOPAGE S PSOPAGE=PSOPAGE+1
95 .I PSOFORM W !,"Address changes for "_$G(PSOASN) Q
96 .W !,"Address changes for ALL Patients"
97 W !,"made between "_$G(PSOSDTX)_" and "_$G(PSOEDTX)
98 W !,PSOLINE
99 Q
100MESS ;
101 W !!,"Nothing queued to print.",!
102 Q
103NAME ;Set name(ssn)
104 K VA S DFN=PSONX D PID^VADPT6
105 S PSONSSN=$G(PSONI)_" ("_$E(VA("PID"),5,12)_")"
106 K VA
107 Q
108PRALL ;Print data for all patients
109 S PSOAFLAG=0
110 W !!," Patient: ",$G(PSONSSN) I ($Y+5)>IOSL D HD Q:PSOUT
111PRONE ;Print data for one patient
112 D CON W !,"Date/time of edit: ",$G(PSOADATE) I ($Y+5)>IOSL D HD Q:PSOUT
113 D CON W !," Field edited: ",$G(PSOADFF) I ($Y+5)>IOSL D HD Q:PSOUT
114 D CON W !," Edited by: ",$G(PSOADUSR) I ($Y+5)>IOSL D HD Q:PSOUT
115 D CON W !," Option/Protocol: ",$G(PSOAOPT) I ($Y+5)>IOSL D HD Q:PSOUT
116 D CON W !," Old Value: ",$S($P($G(^DIA(PSOFILE,PSOADXX,2)),"^")'="":$P($G(^(2)),"^"),1:"<no previous value>") I ($Y+5)>IOSL D HD Q:PSOUT
117 D CON W !," New Value: ",$S($P($G(^DIA(PSOFILE,PSOADXX,3)),"^")'="":$P($G(^(3)),"^"),1:"<no current value>") I ($Y+5)>IOSL D HD
118 Q
119CON ;
120 I PSOAFLAG,'PSOFORM W !," Patient (cont.): ",$G(PSONSSN) S PSOAFLAG=0
121 Q
122FLD ;Set field value
123 K PSOADF D FIELD^DID(PSOFILE,$P(PSOADND,"^",3),"","LABEL","PSOADF")
124 S PSOADFF=$G(PSOADF("LABEL"))
125USR ;Set user value
126 S PSOADUSR=$P(PSOADND,"^",4) I 'PSOADUSR S PSOADUSR="UNKNOWN"
127 I PSOADUSR'="UNKNOWN" K DIC S DIC="^VA(200,",DIC(0)="MZO",X="`"_PSOADUSR D ^DIC S PSOADUSR=$P($G(Y),"^",2) K DIC
128 I $G(PSOADUSR)="" S PSOADUSR="UNKNOWN"
129PROT ;Set value of protocol or option
130 S (PSOAOPT,PSOAOPTB,PSOAOPTC)=""
131 I $G(^DIA(PSOFILE,PSOADXX,4.1))="" S PSOAOPT="/" Q
132 S PSOAOPTA=$P($G(^DIA(PSOFILE,PSOADXX,4.1)),"^")
133 I PSOAOPTA K DIQ,DIC,PSOAOPTZ S DIC=19,DR=".01",DA=PSOAOPTA,DIQ(0)="E",DIQ="PSOAOPTZ" D EN^DIQ1 S PSOAOPTB=$G(PSOAOPTZ(19,PSOAOPTA,.01,"E")) K DIQ,DA,DR,PSOAOPTZ
134 S PSOAOPTA=$P($G(^DIA(PSOFILE,PSOADXX,4.1)),"^",2)
135 K PSOAOPTZ I $P(PSOAOPTA,";",2)="ORD(101," K DIC S DIC=101,DR=".01",DA=+PSOAOPTA,DIQ(0)="E",DIQ="PSOAOPTZ" D EN^DIQ1 S PSOAOPTC=$G(PSOAOPTZ(101,+PSOAOPTA,.01,"E")) K DA,DR,DIC,DIQ,PSOAOPTZ
136 I $P(PSOAOPTA,";",2)'="ORD(101,",+PSOAOPTA K DIC,DIQ S DIC=19,DR=".01",DA=+PSOAOPTA,DIQ(0)="E",DIQ="PSOAOPTZ" D EN^DIQ1 S PSOAOPTC=$G(PSOAOPTZ(19,+PSOAOPTA,.01,"E")) K PSOAOPTZ,DIC,DA,DR,DIQ
137 S PSOAOPT=$G(PSOAOPTB)_"/"_$G(PSOAOPTC)
138 Q
Note: See TracBrowser for help on using the repository browser.