source: FOIAVistA/trunk/r/DSS_EXTRACTS-ECX/ECXALAB.m@ 1397

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

initial load of FOIAVistA 6/30/08 version

File size: 5.4 KB
Line 
1ECXALAB ;ALB/JAP - ECS Extract Audit Report ;Oct 23, 1997
2 ;;3.0;DSS EXTRACTS;**1,8**;Dec 22, 1997
3 ;
4EN ;entry point for LAB extract audit report
5 ;this audit report can be used for extracts done with
6 ;either ECXLABN or ECXLABO
7 N %X,%Y,X,Y,DIC,DA,DR,DIQ,DIR
8 S ECXERR=0
9 ;ecxaud=0 for 'extract' audit
10 S ECXHEAD="LAB",ECXAUD=0
11 W !!,"Setup for ",ECXHEAD," Extract Audit Report --",!!
12 ;select extract
13 D AUDIT^ECXUTLA(ECXHEAD,.ECXERR,.ECXARRAY,ECXAUD)
14 Q:ECXERR
15 W !!
16 ;get the dss site name for report header
17 S ECXALL=1 D DEFAULT^ECXDVSN(.ECXDIV,ECXALL,.ECXERR)
18 Q:ECXERR=1
19 S DIR(0)="Y",DIR("A")="Do you want the "_ECXHEAD_" extract audit report for all Accession Areas"
20 S DIR("B")="NO" D ^DIR K DIR
21 I $G(DIRUT) S ECXERR=1 Q
22 ;if y=0 i.e., 'no', then ecxall=0 i.e., 'selected'
23 S ECXALL=Y
24 I ECXERR=1 D Q
25 .W !!,?5,"Try again later... exiting.",!
26 .D AUDIT^ECXKILL
27 ;select accession areas; all accession areas if ecxall=1
28 S X=ECXARRAY("START") D ^%DT S ECXSTART=Y S X=ECXARRAY("END") D ^%DT S ECXEND=Y
29 D LAB^ECXDVSN1(.ECXACC,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 W !
35 S ECXPGM="PROCESS^ECXALAB",ECXDESC="LAB Extract Audit Report"
36 S ECXSAVE("ECXHEAD")="",ECXSAVE("ECXALL")="",ECXSAVE("ECXACC(")="",ECXSAVE("ECXDIV(")="",ECXSAVE("ECXARRAY(")=""
37 W !
38 D DEVICE^ECXUTLA(ECXPGM,ECXDESC,.ECXSAVE)
39 I ECXSAVE("POP")=1 D Q
40 .W !!,?5,"Try again later... exiting.",!
41 .D AUDIT^ECXKILL
42 I ECXSAVE("ZTSK")=0 D
43 .K ECXSAVE,ECXPGM,ECXDESC
44 .D PROCESS^ECXALAB
45 I IO'=IO(0) D ^%ZISC
46 D HOME^%ZIS
47 D AUDIT^ECXKILL
48 Q
49 ;
50PROCESS ;process data in file #727.813
51 N X,Y,JJ,LMIP,IEN,DATA,DATE,ACC,ACCNM,WKLDNM,WKLD,FILE,QQFLG,CNT
52 K ^TMP($J,"ECXAUD")
53 S (CNT,QQFLG)=0
54 ;see if site is using lmip codes
55 S LMIP=+$G(^ECX(728,1,"LMIP"))
56 S ECXEXT=ECXARRAY("EXTRACT"),ECXDEF=ECXARRAY("DEF")
57 S X=ECXARRAY("START") D ^%DT S ECXSTART=Y S X=ECXARRAY("END") D ^%DT S ECXEND=Y
58 ;get run date in external format
59 D NOW^%DTC S Y=$E(%,1,12) D DD^%DT S ECXRUN=Y
60 ;setup acc. area array by name
61 S ACC="" F S ACC=$O(ECXACC(ACC)) Q:ACC="" D
62 .S ACCNM=$P(ECXACC(ACC),U,1),ACCAB=$P(ECXACC(ACC),U,2),ACC(ACCAB)=ACCNM_" ("_ACCAB_")"
63 ;get records within date range and accession area
64 S IEN="" F S IEN=$O(^ECX(727.813,"AC",ECXEXT,IEN)) Q:IEN="" D Q:QQFLG
65 .S DATA=^ECX(727.813,IEN,0),DATE=$P(DATA,U,9),ACC=$P(DATA,U,11)
66 .;convert free text date to fm internal format date
67 .S $E(DATE,1,2)=$E(DATE,1,2)-17
68 .Q:$L(DATE)<7 Q:(DATE<ECXSTART) Q:(DATE>ECXEND)
69 .Q:'$D(ACC(ACC))
70 .S ACCNM=$P(ACC(ACC),U,1)
71 .S WKLD="",WKLD=$P(DATA,U,20) D
72 ..S WKLDNM="" I WKLD]"" S X=WKLD,DIC="^LAM(",DIC(0)="MX" D ^DIC S WKLDNM=$P(Y,U,2)
73 ..I WKLD="" S:LMIP=1 WKLD="Unknown" S:LMIP=0 WKLD="NA"
74 ..I WKLDNM="" S WKLDNM="Unknown "_WKLD
75 .S FILE=$P(DATA,U,18)
76 .Q:((FILE'=2)&(FILE'=67))
77 .I '$D(^TMP($J,"ECXAUD",ACCNM,WKLDNM)) S ^TMP($J,"ECXAUD",ACCNM,WKLDNM)=0_U_0_U_WKLD
78 .I FILE=2 S $P(^(WKLDNM),U,1)=$P(^TMP($J,"ECXAUD",ACCNM,WKLDNM),U,1)+1,CNT=CNT+1
79 .I FILE=67 S $P(^(WKLDNM),U,2)=$P(^TMP($J,"ECXAUD",ACCNM,WKLDNM),U,2)+1,CNT=CNT+1
80 .I $D(ZTQUEUED),(CNT>499),'(CNT#500),$$S^%ZTLOAD S QQFLG=1,ZTSTOP=1 K ZTREQ
81 ;print the report
82 D PRINT
83 D AUDIT^ECXKILL
84 Q
85 ;
86PRINT ;print the LAB audit report by accession area and test
87 N SS,LN,PG,QFLG,TOTP,TOTR,GTOT,DIV,DIVNM,ACCAB,DIR,DR,DIRUT,DTOUT,DUOUT
88 U IO
89 I $D(ZTQUEUED),$$S^%ZTLOAD S ZTSTOP=1 K ZTREQ Q
90 S (QFLG,PG)=0,$P(LN,"-",80)="",ACCAB="",DIV="",DIV=$O(ECXDIV(DIV)) D HEADER
91 F S ACCAB=$O(ACC(ACCAB)) Q:ACCAB="" D Q:QFLG
92 .S ACCNM=ACC(ACCAB),GTOT("P")=0,GTOT("R")=0
93 .;write the accession area name
94 .D:($Y+3>IOSL) HEADER Q:QFLG W !,ACCNM
95 .I '$D(^TMP($J,"ECXAUD",ACCNM)) D Q
96 ..W !,?3,"No data available for this Accession Area.",!!
97 .I $D(^TMP($J,"ECXAUD",ACCNM)) S WKLDNM="" F S WKLDNM=$O(^TMP($J,"ECXAUD",ACCNM,WKLDNM)) Q:WKLDNM="" D Q:QFLG
98 ..S TOTP=$P(^TMP($J,"ECXAUD",ACCNM,WKLDNM),U,1),TOTR=$P(^(WKLDNM),U,2),WKLD=$P(^(WKLDNM),U,3)
99 ..S GTOT("P")=GTOT("P")+TOTP,GTOT("R")=GTOT("R")+TOTR
100 ..;write the test data
101 ..D:($Y+3>IOSL) HEADER Q:QFLG W !,?3,$E(WKLDNM,1,36),?40,WKLD,?56,$$RJ^XLFSTR(TOTP,5," "),?68,$$RJ^XLFSTR(TOTR,5," ")
102 .;write the accession area grandtotal
103 .D:($Y+3>IOSL) HEADER Q:QFLG W !,?3,$E(LN,1,70)
104 .D:($Y+3>IOSL) HEADER Q:QFLG W !,"Total for "_ACCNM_":",?56,$$RJ^XLFSTR(GTOT("P"),5," "),?68,$$RJ^XLFSTR(GTOT("R"),5," "),!!
105 ;print the audit descriptive narrative
106 I $E(IOST)'="C" D
107 .W @IOF S PG=PG+1
108 .W !,ECXARRAY("TYPE")_" ("_ECXHEAD_") Extract Audit Report"
109 .W !,"DSS Extract Log #: "_ECXEXT
110 .W !,"Date Range of Audit: "_ECXARRAY("START")_" to "_ECXARRAY("END")
111 .W !,"Report Run Date/Time: "_ECXRUN,?68,"Page: ",PG
112 .W !!,LN,!!
113 .S DIC="^ECX(727.1,",DA=ECXARRAY("DEF"),DR="1" D EN^DIQ
114 I $E(IOST)="C",'QFLG D
115 .S SS=22-$Y F JJ=1:1:SS W !
116 .S DIR(0)="E" W ! D ^DIR K DIR
117 Q
118 ;
119HEADER ;header and page control
120 N JJ,SS
121 I $E(IOST)="C" D
122 .S SS=22-$Y F JJ=1:1:SS W !
123 .I PG>0 S DIR(0)="E" W ! D ^DIR K DIR S:'Y QFLG=1
124 Q:QFLG
125 W:$Y!($E(IOST)="C") @IOF S PG=PG+1
126 W !,ECXARRAY("TYPE")_" ("_ECXHEAD_") Extract Audit Report"
127 W !,"DSS Extract Log #: "_ECXARRAY("EXTRACT")
128 W !,"Date Range of Audit: "_ECXARRAY("START")_" to "_ECXARRAY("END")
129 W !,"Report Run Date/Time: "_ECXRUN
130 W !,"DSS Site: "_$P(ECXDIV(DIV),U,2)_" ("_$P(ECXDIV(DIV),U,3)_")",?68,"Page: "_PG
131 W !!,"Accession Area (Feeder Location)",?40,"LMIP",?56,"# of Tests",?68,"# of Tests"
132 W !,?3,"Procedure",?40,"Code",?56,"(Patients)",?68,"(Referrals)"
133 W !,LN,!
134 Q
Note: See TracBrowser for help on using the repository browser.