source: FOIAVistA/trunk/r/DSS_EXTRACTS-ECX/ECXARAD.m@ 1535

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

initial load of FOIAVistA 6/30/08 version

File size: 5.8 KB
Line 
1ECXARAD ;ALB/JAP - RAD Extract Audit Report ;Oct 16, 1997
2 ;;3.0;DSS EXTRACTS;**8,33,39**;Dec 22, 1997
3 ;
4EN ;entry point for RAD extract audit report
5 ;select extract
6 N %X,%Y,X,Y,DIC,DA,DR,DIQ,DIR,SITES,ECX
7 ;ecxaud=0 for 'extract' audit
8 S ECXERR=0
9 S ECXHEAD="RAD",ECXAUD=0
10 W !!,"Setup for ",ECXHEAD," Extract Audit Report --",!!
11 D AUDIT^ECXUTLA(ECXHEAD,.ECXERR,.ECXARRAY,ECXAUD)
12 Q:ECXERR
13 ;determine if facility is multidivisional
14 K ECX D FILE^DID(79,,"ENTRIES","ECX") S SITES=ECX("ENTRIES") K ECX
15 I SITES=1 S ECXALL=1
16 I SITES>1 D
17 .W !!
18 .S DIR(0)="Y",DIR("A")="Do you want the "_ECXHEAD_" extract audit report for all divisions"
19 .S DIR("B")="NO" D ^DIR K DIR
20 .I $G(DIRUT) S ECXERR=1 Q
21 .;if y=0 i.e., 'no', then ecxall=0 i.e., 'selected'
22 .S ECXALL=Y
23 I ECXERR=1 D Q
24 .W !!,?5,"Try again later... exiting.",!
25 .D AUDIT^ECXKILL
26 ;select divisions/sites; all divisions if ecxall=1
27 W !
28 S ECXSTART=ECXARRAY("START"),ECXEND=ECXARRAY("END")
29 D RAD^ECXDVSN2(.ECXDIV,ECXALL,.ECXERR)
30 I ECXERR=1 D Q
31 .W !!,?5,"Try again later... exiting.",!
32 .D AUDIT^ECXKILL
33 ;determine output device and queue if requested
34 S ECXPGM="PROCESS^ECXARAD",ECXDESC="RAD Extract Audit Report"
35 S ECXSAVE("ECXHEAD")="",ECXSAVE("ECXALL")="",ECXSAVE("ECXDIV(")="",ECXSAVE("ECXARRAY(")=""
36 W !
37 D DEVICE^ECXUTLA(ECXPGM,ECXDESC,.ECXSAVE)
38 I ECXSAVE("POP")=1 D Q
39 .W !!,?5,"Try again later... exiting.",!
40 .D AUDIT^ECXKILL
41 I ECXSAVE("ZTSK")=0 D
42 .K ECXSAVE,ECXPGM,ECXDESC
43 .D PROCESS^ECXARAD
44 I IO'=IO(0) D ^%ZISC
45 D HOME^%ZIS
46 D AUDIT^ECXKILL
47 Q
48 ;
49PROCESS ;process data in file #727.814
50 N X,Y,JJ,DIV,IEN,DATA,DATE,ECX,PAT,TYPE,IMNM,IMAB,PROC,PROCN,CPT,DIC,DIQ,DR,DA,QQFLG,CNT
51 K ^TMP($J,"ECXAUD")
52 S (CNT,QQFLG)=0
53 S ECXEXT=ECXARRAY("EXTRACT"),ECXDEF=ECXARRAY("DEF")
54 S X=ECXARRAY("START") D ^%DT S ECXSTART=Y S X=ECXARRAY("END") D ^%DT S ECXEND=Y
55 ;get run date in external format
56 D NOW^%DTC S Y=$E(%,1,12) D DD^%DT S ECXRUN=Y
57 ;setup array of imaging types
58 S TYPE=0 F S TYPE=$O(^RA(79.2,TYPE)) Q:+TYPE<1 D
59 .K ECX S DIC="^RA(79.2,",DR=".01;3",DIQ="ECX",DIQ(0)="I",DA=TYPE D EN^DIQ1
60 .S TYPE(TYPE)=ECX(79.2,TYPE,.01,"I")_U_ECX(79.2,TYPE,3,"I")
61 ;get records within date range and radiology site(s)
62 S IEN="" F S IEN=$O(^ECX(727.814,"AC",ECXEXT,IEN)) Q:IEN="" D Q:QQFLG
63 .S DATA=^ECX(727.814,IEN,0),DATE=$P(DATA,U,9),DIV=$P(DATA,U,4)
64 .;convert free text date to fm internal format date
65 .S $E(DATE,1,2)=$E(DATE,1,2)-17
66 .Q:$L(DATE)<7 Q:(DATE<ECXSTART) Q:(DATE>ECXEND)
67 .Q:'$D(ECXDIV(DIV))
68 .S PAT=$P(DATA,U,8),TYPE=$P(DATA,U,21),PROC=$P(DATA,U,11)
69 .S CPT=$E($P(DATA,U,10),1,5),CPT="A"_$$RJ^XLFSTR(CPT,5,0)
70 .S IMNM=$P(TYPE(TYPE),U,1),IMAB=$P(TYPE(TYPE),U,2)
71 .K ECX S DIC="^RAMIS(71,",DR=".01",DIQ="ECX",DIQ(0)="I",DA=+PROC D EN^DIQ1
72 .S PROCN=$G(ECX(71,+PROC,.01,"I")) I PROCN="" S PROCN="Unknown"
73 .;tally procedures; 1st piece is outpatient total, 2nd piece is inpatient total
74 .I '$D(^TMP($J,"ECXAUD",DIV,IMNM,CPT)) S ^TMP($J,"ECXAUD",DIV,IMNM,CPT)=0_U_0_U_PROCN
75 .I PAT=1!(PAT="O") S $P(^(CPT),U,1)=$P(^TMP($J,"ECXAUD",DIV,IMNM,CPT),U,1)+1,CNT=CNT+1
76 .I PAT=3!(PAT="I") S $P(^(CPT),U,2)=$P(^TMP($J,"ECXAUD",DIV,IMNM,CPT),U,2)+1,CNT=CNT+1
77 .I $D(ZTQUEUED),(CNT>499),'(CNT#500),$$S^%ZTLOAD S QQFLG=1,ZTSTOP=1 K ZTREQ
78 ;print the report
79 D PRINT
80 D AUDIT^ECXKILL
81 Q
82 ;
83PRINT ;print the RAD audit report by radiology site
84 N LN,P,PG,QFLG,TOT,STOT,GTOT,DIVNM,IMAG,IMTYPE,T,SS,DIC,DIR,DR,DIRUT,DTOUT,DUOUT
85 U IO
86 I $D(ZTQUEUED),$$S^%ZTLOAD S ZTSTOP=1 K ZTREQ Q
87 S (QFLG,PG)=0,$P(LN,"-",80)="",DIV=""
88 ;arrange type array by name
89 S T=0 F S T=$O(TYPE(T)) Q:T="" S IMNM=$P(TYPE(T),U,1),IMAG(IMNM)=T
90 F S DIV=$O(ECXDIV(DIV)) Q:DIV="" D Q:QFLG
91 .S DIVNM=$P(ECXDIV(DIV),U,2)_" ("_DIV_")",GTOT(1)=0,GTOT(3)=0 D HEADER
92 .I '$D(^TMP($J,"ECXAUD",DIV)) D Q
93 ..W !!,?5,"No data available for this Radiology Division.",!!
94 .I $D(^TMP($J,"ECXAUD",DIV)) S IMNM="" F S IMNM=$O(^TMP($J,"ECXAUD",DIV,IMNM)) Q:IMNM="" D Q:QFLG
95 ..S STOT(1)=0,STOT(3)=0,IMTYPE=IMAG(IMNM),CPT=""
96 ..;write the imaging type name
97 ..D:($Y+3>IOSL) HEADER Q:QFLG W !,IMNM_" ("_DIV_"-"_IMTYPE_")",!
98 ..F S CPT=$O(^TMP($J,"ECXAUD",DIV,IMNM,CPT)) Q:CPT="" S TOT(1)=$P(^(CPT),U,1),TOT(3)=$P(^(CPT),U,2),PROCN=$P(^(CPT),U,3) D Q:QFLG
99 ...S STOT(1)=STOT(1)+TOT(1),STOT(3)=STOT(3)+TOT(3)
100 ...S GTOT(1)=GTOT(1)+TOT(1),GTOT(3)=GTOT(3)+TOT(3)
101 ...;write procedure and total
102 ...D:($Y+3>IOSL) HEADER Q:QFLG W ?3,$E(CPT,2,6),?14,$E(PROCN,1,38),?60,$$RJ^XLFSTR(TOT(3),5," "),?70,$$RJ^XLFSTR(TOT(1),5," "),!
103 ..;write the unit subtotal
104 ..D:($Y+3>IOSL) HEADER Q:QFLG W !,?5,$E(LN,1,74)
105 ..D:($Y+3>IOSL) HEADER Q:QFLG W !,"Sub-totals for "_IMNM_" ("_DIV_"-"_IMTYPE_"):",?60,$$RJ^XLFSTR(STOT(3),5," "),?70,$$RJ^XLFSTR(STOT(1),5," "),!
106 .;write the division grandtotal
107 .D:($Y+3>IOSL) HEADER Q:QFLG W !!,"Grand Total for Division "_DIVNM_":",?60,$$RJ^XLFSTR(GTOT(3),5," "),?70,$$RJ^XLFSTR(GTOT(1),5," ")
108 ;print the audit descriptive narrative
109 I $E(IOST)'="C" D
110 .W @IOF S PG=PG+1
111 .W !,ECXARRAY("TYPE")_" ("_ECXHEAD_") Extract Audit Report"
112 .W !,"DSS Extract Log #: "_ECXEXT
113 .W !,"Date Range of Audit: "_ECXARRAY("START")_" to "_ECXARRAY("END")
114 .W !,"Report Run Date/Time: "_ECXRUN,?68,"Page: ",PG
115 .W !!,LN,!!
116 .S DIC="^ECX(727.1,",DA=ECXARRAY("DEF"),DR="1" D EN^DIQ
117 I $E(IOST)="C",'QFLG D
118 .S SS=22-$Y F JJ=1:1:SS W !
119 .S DIR(0)="E" W ! D ^DIR K DIR
120 Q
121 ;
122HEADER ;header and page control
123 N JJ,SS
124 I $E(IOST)="C" D
125 .S SS=22-$Y F JJ=1:1:SS W !
126 .I PG>0 S DIR(0)="E" W ! D ^DIR K DIR S:'Y QFLG=1
127 Q:QFLG
128 W:$Y!($E(IOST)="C") @IOF S PG=PG+1
129 W !,ECXARRAY("TYPE")_" ("_ECXHEAD_") Extract Audit Report"
130 W !,"DSS Extract Log #: "_ECXARRAY("EXTRACT")
131 W !,"Date Range of Audit: "_ECXARRAY("START")_" to "_ECXARRAY("END")
132 W !,"Report Run Date/Time: "_ECXRUN
133 W !,"Radiology Division: "_$P(ECXDIV(DIV),U,2)_" ("_DIV_")",?60,"Page: "_PG
134 W !!,"Imaging Type (Feeder Location)",?60,"# of Procedures"
135 W !,?3,"CPT Code",?14,"Procedure",?60,"Inpt.",?70,"Outpt."
136 W !,LN,!
137 Q
Note: See TracBrowser for help on using the repository browser.