source: FOIAVistA/trunk/r/DSS_EXTRACTS-ECX/ECXASUR.m@ 1608

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

initial load of FOIAVistA 6/30/08 version

File size: 5.7 KB
Line 
1ECXASUR ;ALB/JAP - SUR Extract Audit Report ; 4/26/02 11:16am
2 ;;3.0;DSS EXTRACTS;**8,33,44**;Dec 22, 1997
3 ;
4EN ;entry point for SUR 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="SUR",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(133,,"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 SUR^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^ECXASUR",ECXDESC="SUR 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^ECXASUR
44 I IO'=IO(0) D ^%ZISC
45 D HOME^%ZIS
46 D AUDIT^ECXKILL
47 Q
48 ;
49PROCESS ;process data in file #727.811
50 N X,Y,JJ,DIV,IEN,DATA,DATE,CASE,CASES,OR,LOC,PROC,PROCN,PSI,CAN,CPT,DIC,QQFLG,CNT
51 K ^TMP($J,"ECXAUD"),^TMP($J,"ECXS")
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 ;get records within date range and surgery site(s)
58 S IEN="" F S IEN=$O(^ECX(727.811,"AC",ECXEXT,IEN)) Q:IEN="" D Q:QQFLG
59 .S DATA=^ECX(727.811,IEN,0),DATA1=^(1),DATE=$P(DATA,U,9)
60 .S DIV=$P(DATA,U,4)
61 .;convert free text date to fm internal format date
62 .S $E(DATE,1,2)=$E(DATE,1,2)-17
63 .Q:$L(DATE)<7 Q:(DATE<ECXSTART) Q:(DATE>ECXEND)
64 .Q:'$D(ECXDIV(DIV))
65 .Q:$P(DATA,U,17)="I"
66 .S CASE=$P(DATA,U,10),OR=$P(DATA,U,12),PSI=$P(DATA,U,17)
67 .S CAN=$P(DATA,U,28)
68 .S PROC=$E($P(DATA1,U,11),1,5)
69 .Q:(PROC="")&(PSI="I")
70 .S (CPT,PROCN)="" I PROC]"" D
71 ..;from cpt code get procedure name; variable cpt should be same as variable proc
72 ..K Y S DIC="^ICPT(",DIC(0)="XZ",X=PROC D ^DIC
73 ..S CPT=$P($G(Y(0)),U,1),PROCN=$P($G(Y(0)),U,2)
74 .S:CPT="" CPT="Unknown" S:PROCN="" PROCN="Unknown" S CPT="A"_CPT
75 .S LOC=$S(OR="":2,1:1)
76 .I CAN'="" S LOC=3
77 .;tally procedures by location and division
78 .I '$D(^TMP($J,"ECXAUD",DIV,LOC,CPT)) S ^TMP($J,"ECXAUD",DIV,LOC,CPT)=0_U_PROCN
79 .S $P(^(CPT),U,1)=$P(^TMP($J,"ECXAUD",DIV,LOC,CPT),U,1)+1,CNT=CNT+1
80 .I $D(ZTQUEUED),(CNT>499),'(CNT#500),$$S^%ZTLOAD S QQFLG=1,ZTSTOP=1 K ZTREQ Q
81 .I '$D(^TMP($J,"ECXS",DIV,LOC,CASE)) S ^TMP($J,"ECXS",DIV,LOC,CASE)=""
82 ;total cases for each division and location
83 I $D(ZTQUEUED),$$S^%ZTLOAD S ZTSTOP=1 K ZTREQ Q
84 S DIV="" F S DIV=$O(^TMP($J,"ECXS",DIV)) Q:DIV="" F LOC=1:1:3 S CASES(DIV,LOC)=0,CASE="" D
85 .F S CASE=$O(^TMP($J,"ECXS",DIV,LOC,CASE)) Q:CASE="" S CASES(DIV,LOC)=CASES(DIV,LOC)+1
86 K ^TMP($J,"ECXS")
87 ;print the report
88 D PRINT
89 D AUDIT^ECXKILL
90 Q
91 ;
92PRINT ;print the SUR audit report by location and division
93 N LN,PG,QFLG,TOT,GTOT,DIVNM,CPT,CPTN,PROCN,LOCNM,LOCNMC,SS,DIR,DR,DIRUT,DTOUT,DUOUT
94 U IO
95 I $D(ZTQUEUED),$$S^%ZTLOAD S ZTSTOP=1 K ZTREQ Q
96 S (QFLG,PG)=0,$P(LN,"-",80)="",DIV=""
97 F S DIV=$O(ECXDIV(DIV)) Q:DIV="" F LOC=1:1:3 D Q:QFLG
98 .S DIVNM=$P(ECXDIV(DIV),U,2)_" ("_DIV_")",GTOT(LOC)=0
99 .S LOCNM=$S(LOC=1:"O.R. Surgical Procedures",LOC=2:"Non-O.R. Surgical Procedures",1:"Cancelled/Aborted Procedures")
100 .D HEADER
101 .I '$D(^TMP($J,"ECXAUD",DIV,LOC)) D
102 ..W !!,?3,"No data available for "_LOCNM_".",!!
103 .I $D(^TMP($J,"ECXAUD",DIV,LOC)) S CPT="" F S CPT=$O(^TMP($J,"ECXAUD",DIV,LOC,CPT)) Q:CPT="" S TOT(LOC)=$P(^(CPT),U,1),PROCN=$P(^(CPT),U,2),CPTN=$E(CPT,2,99) D Q:QFLG
104 ..S GTOT(LOC)=GTOT(LOC)+TOT(LOC)
105 ..;write procedure and total
106 ..D:($Y+3>IOSL) HEADER Q:QFLG W !,?3,CPTN,?14,$E(PROCN,1,40),?63,$$RJ^XLFSTR(TOT(LOC),5," ")
107 .;write the division totals
108 .D:($Y+3>IOSL) HEADER Q:QFLG W !,?3,$E(LN,1,65)
109 .D:($Y+3>IOSL) HEADER Q:QFLG W !!,"For Division "_DIVNM_"--"
110 .D:($Y+3>IOSL) HEADER Q:QFLG W !,?3,"Total "_LOCNM_":",?63,$$RJ^XLFSTR(GTOT(LOC),5," ")
111 .S LOCNMC=$P(LOCNM,"Pro",1) S:'$D(CASES(DIV,LOC)) CASES(DIV,LOC)=0
112 .D:($Y+3>IOSL) HEADER Q:QFLG W !,?3,"Total "_LOCNMC_"Cases:",?63,$$RJ^XLFSTR(CASES(DIV,LOC),5," ")
113 ;print the audit descriptive narrative
114 I $E(IOST)'="C" D
115 .W @IOF S PG=PG+1
116 .W !,ECXARRAY("TYPE")_" ("_ECXHEAD_") Extract Audit Report"
117 .W !,"DSS Extract Log #: "_ECXEXT
118 .W !,"Date Range of Audit: "_ECXARRAY("START")_" to "_ECXARRAY("END")
119 .W !,"Report Run Date/Time: "_ECXRUN,?68,"Page: ",PG
120 .W !!,LN,!!
121 .S DIC="^ECX(727.1,",DA=ECXARRAY("DEF"),DR="1" D EN^DIQ
122 I $E(IOST)="C",'QFLG D
123 .S SS=22-$Y F JJ=1:1:SS W !
124 .S DIR(0)="E" W ! D ^DIR K DIR
125 Q
126 ;
127HEADER ;header and page control
128 N JJ,SS
129 I $E(IOST)="C" D
130 .S SS=22-$Y F JJ=1:1:SS W !
131 .I PG>0 S DIR(0)="E" W ! D ^DIR K DIR S:'Y QFLG=1
132 Q:QFLG
133 W:$Y!($E(IOST)="C") @IOF S PG=PG+1
134 W !,ECXARRAY("TYPE")_" ("_ECXHEAD_") Extract Audit Report"
135 W !,"DSS Extract Log #: "_ECXARRAY("EXTRACT")
136 W !,"Date Range of Audit: "_ECXARRAY("START")_" to "_ECXARRAY("END")
137 W !,"Report Run Date/Time: "_ECXRUN
138 W !,"Surgery Division: "_$P(ECXDIV(DIV),U,2)_" ("_DIV_")",?63,"Page: "_PG
139 W !!,LOCNM
140 W !,?3,"CPT Code",?14,"Procedure",?63,"# of Procedures"
141 W !,LN,!
142 Q
Note: See TracBrowser for help on using the repository browser.