source: FOIAVistA/trunk/r/ZZREGIONAL-A1C-A5C-CRHD-RGED-RGUT-RGWB-RG/RGMTAUDP.m@ 1310

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

initial load of FOIAVistA 6/30/08 version

File size: 7.6 KB
Line 
1RGMTAUDP ;BIR/CML,PTD-MPI/PD AUDIT File Print of Patient Data ;01/06/99
2 ;;1.0;CLINICAL INFO RESOURCE NETWORK;**19,30,46**;30 Apr 99
3 ;Reference to ^DD(2 supported by IA #2695.
4 ;Reference to ^DIA(2 and data derived from the AUDIT file (#1.1)
5 ;supported by IA #2097 and #2602.
6 ;Reference to ^ORD(101 supported by IA #2596
7 ;
8BEGIN ;
9 S QFLG=1
10 W @IOF
11 W !,"This option prints a customized report of information stored in the AUDIT"
12 W !,"file (#1.1) for fields being audited in the PATIENT file (#2). For a"
13 W !,"specified date range, you can view all audited fields or selected fields."
14 W !,"You can also opt to print only edits that were done by a specific user."
15 W !!,"- If selected fields are viewed, you can choose to see data for all or"
16 W !," selected patients."
17 W !,"- If ALL audited fields are viewed, you must choose patients to examine."
18 ;
19ASKFLD ;Ask for Data Fields
20 I '$O(^DD(2,"AUDIT",0)) W !!,"No fields are currently being audited in the PATIENT file (#2)." G QUIT
21 W !
22 K DIR S DIR(0)="SAM^A:ALL;S:SELECTED;"
23 S DIR("A")="Do you want to see (A)LL or (S)ELECTED audited fields? "
24 S DIR("B")="A"
25 S DIR("?",1)="Enter:"
26 S DIR("?",2)=" ""A"" to see ALL audited fields in the PATIENT file (#2)."
27 S DIR("?")=" ""S"" to select specific audited fields."
28 D ^DIR G:$D(DIRUT) QUIT S ANS1=Y
29 ;
30FLDLOOP ;
31 W ! K FLD
32 ;stuff all fields
33 I ANS1="A" D G ASKPAT
34 .S FLD=0 F S FLD=$O(^DD(2,"AUDIT",FLD)) Q:'FLD S FLD(FLD)=""
35 ;ask for specific fields
36 K DIR S DIR(0)="NAOC^.0000001:9999999:7^K:'$D(^DD(2,""AUDIT"",X)) X S RGERR=1"
37 S DIR("A")="Select FIELD NUMBER of audited field (enter ""?"" for list): "
38 S DIR("?")="^D FLDLIST^RGMTAUDP"
39 F QQ=0:0 S RGERR=0 D ^DIR Q:$D(DIRUT) S FLD(+Y)=""
40 ;
41ASKPAT ;Ask for Patient
42 I '$O(FLD(0))!($D(DUOUT)) S QFLG=1 G QUIT
43 I ANS1="A" S ANS2="S" G PATLOOP
44 K DIR S DIR(0)="SAM^A:ALL;S:SELECTED;"
45 S DIR("A")="Do you want to see audited data for (A)LL or (S)ELECTED patients? "
46 S DIR("B")="S"
47 S DIR("?",1)="Enter:"
48 S DIR("?",2)=" ""A"" to see audited fields for ALL patients."
49 S DIR("?")=" ""S"" to select specific patients(s)."
50 W ! D ^DIR G:$D(DIRUT) QUIT S ANS2=Y
51PATLOOP ;
52 W ! K PAT
53 I ANS2="A" S PAT("ALL")="" G ASKDT
54 ;ask for specific patient(s)
55 F QQ=0:0 S DIC="^DPT(",DIC(0)="QEAM",DIC("A")="Select PATIENT: " D ^DIC K DIC Q:Y<0 S RGDFN=+Y D
56 .I '$O(^DIA(2,"B",RGDFN,0)) W $C(7),!?5,"This patient has no audit data available for any date." Q
57 .S PAT(RGDFN)=""
58 ;
59ASKDT ;Ask for Date Range
60 I '$D(PAT)!($D(DUOUT)) S QFLG=1 G QUIT
61 W !!,"Enter date range for data to be included in report."
62 K DIR,DIRUT,DTOUT,DUOUT S DIR(0)="DAO^:DT:EPX",DIR("A")="Beginning Date: " D ^DIR K DIR G:$D(DIRUT) QUIT
63 S RGBDT=Y,DIR(0)="DAO^"_RGBDT_":DT:EPX",DIR("A")="Ending Date: " D ^DIR K DIR G:$D(DIRUT) QUIT S RGEDT=Y
64 ;
65ASKUSER ;Ask if data is wanted only a specific user
66 K USERSCRN
67 W ! S DIR(0)="Y",DIR("B")="No",DIR("A")="Do you want to find only the edits made by a specific user"
68 D ^DIR K DIR I +Y'=1 G DEV
69 ;
70 S DIC="^VA(200,",DIC(0)="QEAM",DIC("A")="Select USER: "
71 D ^DIC K DIC G:+Y<0 QUIT S USERSCRN=+Y
72 ;
73DEV W !!,"The right margin for this report is 80.",!!
74 I ANS2="A" S IOP="Q" W "Because you selected ALL patients, you MUST queue this report.",!!
75 S ZTSAVE("RGBDT")="",ZTSAVE("RGEDT")="",ZTSAVE("ANS2")="",ZTSAVE("FLD(")="",ZTSAVE("PAT(")="",%ZIS("B")=""
76 S ZTSAVE("USERSCRN")=""
77 D EN^XUTMDEVQ("START^RGMTAUDP","MPI/PD - Print AUDIT File Data from the PATIENT file",.ZTSAVE,.%ZIS) I 'POP Q
78 W !,"NO DEVICE SELECTED OR REPORT PRINTED!!"
79 S QFLG=1 G QUIT
80 ;
81START ;
82 K ^TMP("RGMTAUDP",$J),^TMP("RGMTAUDP2",$J) S U="^"
83 S STOP=RGEDT+1
84 I ANS2="A" D
85 .S CNT=0
86 .S RGDFN=0 F S RGDFN=$O(^DIA(2,"B",RGDFN)) Q:'RGDFN S CNT=CNT+1 S:'(CNT#10000) ^TMP("RGMTAUDP",$J,"@@@@","CUR DFN")=RGDFN D LOOP
87 I ANS2="S" D
88 .S RGDFN=0 F S RGDFN=$O(PAT(RGDFN)) Q:'RGDFN D LOOP
89 G PRT
90 ;
91LOOP ;Loop on "B" xref of the AUDIT file
92 Q:'$D(^DPT(RGDFN,0))
93 I ANS2="S" D
94 . S PATNM=$P(^DPT(RGDFN,0),U)_U_RGDFN
95 . I '$O(^DIA(2,"B",RGDFN,0)) S ^TMP("RGMTAUDP2",$J,"NO AUDIT",PATNM)=" has no audit data available for any date."
96 S IEN=0 F S IEN=$O(^DIA(2,"B",RGDFN,IEN)) Q:'IEN D
97 .I $D(^DIA(2,IEN,0)) S IEN0=(^(0)),EDITDT=$P(IEN0,U,2) I EDITDT>RGBDT,EDITDT<STOP D
98 ..S FLD=$P(IEN0,U,3) I $D(FLD(FLD)) D
99 ...S USER=$P(IEN0,U,4)
100 ...I $D(USERSCRN) I USER'=USERSCRN Q
101 ...S PATNM=$P(^DPT(RGDFN,0),U)_U_RGDFN,^TMP("RGMTAUDP",$J,PATNM,EDITDT,IEN)=""
102 I ANS2="S" D
103 . I '$D(^TMP("RGMTAUDP",$J,PATNM)) S ^TMP("RGMTAUDP2",$J,"NO AUDIT",PATNM)=" has no audit data available for selected parameters."
104 Q
105 ;
106PRT ;Print report
107 S (PG,QFLG)=0,U="^",$P(LN,"-",81)="",SITE=$P($$SITE^VASITE(),U,2)
108 S PRGBDT=$$FMTE^XLFDT(RGBDT),PRGEDT=$$FMTE^XLFDT(RGEDT)
109 D NOW^%DTC S HDT=$$FMTE^XLFDT($E(%,1,12))
110 D HDR
111 I '$D(^TMP("RGMTAUDP",$J)) W !!,"No audit data found in this date range for specified parameters." G QUIT
112 S PATNM="@@@@" F S PATNM=$O(^TMP("RGMTAUDP",$J,PATNM)) Q:PATNM="" Q:QFLG D
113 .D:$Y+4>IOSL HDR Q:QFLG
114 .W !!,"==> ",$P(PATNM,U)," (DFN #",$P(PATNM,U,2),")"
115 .S EDITDT=0 F S EDITDT=$O(^TMP("RGMTAUDP",$J,PATNM,EDITDT)) Q:QFLG Q:'EDITDT D
116 ..S IEN=0 F S IEN=$O(^TMP("RGMTAUDP",$J,PATNM,EDITDT,IEN)) Q:QFLG Q:'IEN D
117 ...S PRTDT=$$FMTE^XLFDT($E(EDITDT,1,12))
118 ...S IEN0=^DIA(2,IEN,0)
119 ...K RGARR D FIELD^DID(2,$P(IEN0,U,3),"","LABEL","RGARR")
120 ...S FLD=$G(RGARR("LABEL")) Q:FLD=""
121 ...S USER=$P(IEN0,U,4)
122 ...I 'USER S USER="UNKNOWN"
123 ...I USER'="UNKNOWN" S DIC="^VA(200,",DIC(0)="MZO",X="`"_USER D ^DIC S USER=$P(Y,"^",2)
124 ...S OLD=$G(^DIA(2,IEN,2)) I OLD']"" S OLD="<no previous value>"
125 ...S NEW=$G(^DIA(2,IEN,3)) I NEW']"" S NEW="<no current value>"
126 ...K OPTDA1,OPTDA2,OPTION,OPTNM I $G(^DIA(2,IEN,4.1)) D
127 ....S OPTDA1=+$P(^DIA(2,IEN,4.1),"^")
128 ....I OPTDA1 S DIC=19,DR=".01",DA=OPTDA1,DIQ(0)="EI",DIQ="OPTION" D EN^DIQ1 K DIC,DR,DA,DIQ S OPTION=$G(OPTION(19,OPTDA1,.01,"E"))
129 ....S OPTDA2=$P(^DIA(2,IEN,4.1),"^",2)
130 ....I $P(OPTDA2,";",2)="ORD(101," S DIC=101,DR=".01",DA=+OPTDA2,DIQ(0)="EI",DIQ="OPTION" D EN^DIQ1 K DIC,DR,DA,DIQ S OPTNM=$G(OPTION(101,+OPTDA2,.01,"E")) Q
131 ....I +OPTDA2 S DIC=19,DR=".01",DA=+OPTDA2,DIQ(0)="EI",DIQ="OPTION" D EN^DIQ1 K DIC,DR,DA,DIQ S OPTNM=$G(OPTION(19,+OPTDA2,.01,"E")) Q
132 ...D:$Y+5>IOSL HDR Q:QFLG W !!,PRTDT,?20,FLD,?51,USER,!?20,OLD," / ",NEW
133 ...I $G(OPTION)'="" W !?3,OPTION I $G(OPTNM)'="" W "/",OPTNM
134 I $D(^TMP("RGMTAUDP2",$J,"NO AUDIT")) D
135 . S PATNM="@@@@",RGNAUD="" F S PATNM=$O(^TMP("RGMTAUDP2",$J,"NO AUDIT",PATNM)) Q:PATNM="" D
136 .. Q:QFLG
137 .. S RGNAUD=$P(^TMP("RGMTAUDP2",$J,"NO AUDIT",PATNM),U)
138 .. W !!,"==> ",$P(PATNM,U)," (DFN #",$P(PATNM,U,2),")"_RGNAUD
139 ;
140QUIT ;
141 I $E(IOST,1,2)="C-"&('QFLG) S DIR(0)="E" D D ^DIR K DIR
142 .S SS=22-$Y F JJ=1:1:SS W !
143 K ^TMP("RGMTAUDP",$J),^TMP("RGMTAUDP2",$J)
144 K %,%I,ANS1,ANS2,C,CNT,RGDFN,DIR,DIRUT,DTOUT,DUOUT,EDITDT,FLD,FLDLP,FLDNM,HDR
145 K HDT,IEN,IEN0,JJ,LN,NEW,OLD,OPTDA1,OPTDA2,OPTION,OPTNM,PAT,PATNM,PG,PRGBDT,PRGEDT,PRTDT,QFLG,QQ,RGARR,RGBDT,RGNAUD
146 K RGEDT,RGERR,SITE,SS,STOP,USER,X,Y,ZTSK
147 D ^%ZISC S:$D(ZTQUEUED) ZTREQ="@" Q
148 ;
149HDR ;HEADER
150 I $E(IOST,1,2)="C-" S SS=22-$Y F JJ=1:1:SS W !
151 I $E(IOST,1,2)="C-",PG>0 S DIR(0)="E" W ! D ^DIR K DIR I 'Y S QFLG=1 Q
152 S PG=PG+1 W:$Y!($E(IOST,1,2)="C-") @IOF
153 W !,"PATIENT AUDIT LIST at ",SITE," on ",HDT,?72,"Page: ",PG
154 W !,"Date Range: ",PRGBDT," to ",PRGEDT
155 W !!,"Date/Time Edited",?20,"Field Edited",?51,"Edited By",!?20,"Old Value / New Value"
156 W !?3,"Option/Protocol",!,LN
157 Q
158 ;
159FLDLIST ;Help for Field # List
160 K RG N DIR S QFLG=0 I RGERR W $C(7)," ??"
161 S HDR="Select a FIELD NUMBER from the audited field(s) in the PATIENT file:"
162 W @IOF,HDR,!
163 S FLDLP=0 F S FLDLP=$O(^DD(2,"AUDIT",FLDLP)) Q:'FLDLP Q:QFLG D
164 .I $Y+6>IOSL D Q:QFLG
165 ..S DIR(0)="E" W ! D ^DIR K DIR I 'Y S QFLG=1 Q
166 ..E W @IOF,HDR,!
167 .K RGARR D FIELD^DID(2,FLDLP,"","LABEL","RGARR")
168 .S FLDNM=$G(RGARR("LABEL")) Q:FLDNM=""
169 .W !,FLDLP,?13,FLDNM
170 Q
Note: See TracBrowser for help on using the repository browser.