ECXANUR ;ALB/JAP - NUR Extract Audit Report ;Oct 15, 1997
;;3.0;DSS EXTRACTS;**8**;Dec 22, 1997
;
EN ;entry point for NUR extract audit report
N %X,%Y,X,Y,DIC,DA,DR,DIQ,DIR
S ECXERR=0
;ecxaud=0 for 'extract' audit
S ECXHEAD="NUR",ECXAUD=0
W !!,"Setup for ",ECXHEAD," Extract Audit Report --",!!
;select extract
D AUDIT^ECXUTLA(ECXHEAD,.ECXERR,.ECXARRAY,ECXAUD)
Q:ECXERR
;determine if facility is multidivisional
S DIC="^DG(43,",DA=1,DR="11;",DIQ="ECX",DIQ(0)="I" D EN^DIQ1
I +ECX(43,1,11,"I")=0 S ECXALL=1
I +ECX(43,1,11,"I")=1 D
.W !!
.S DIR(0)="Y",DIR("A")="Do you want the "_ECXHEAD_" extract audit report for all divisions"
.S DIR("B")="NO" D ^DIR K DIR
.I $G(DIRUT) S ECXERR=1 Q
.;if y=0 i.e., 'no', then ecxall=0 i.e., 'selected'
.S ECXALL=Y
I ECXERR=1 D Q
.W !!,?5,"Try again later... exiting.",!
.D AUDIT^ECXKILL
;select divisions/sites; all divisions if ecxall=1
S X=ECXARRAY("START") D ^%DT S ECXSTART=Y S X=ECXARRAY("END") D ^%DT S ECXEND=Y
D NUR^ECXDVSN1(.ECXDIV,ECXALL,.ECXERR)
I ECXERR=1 D Q
.W !!,?5,"Try again later... exiting.",!
.D AUDIT^ECXKILL
;determine output device and queue if requested
W !
S ECXPGM="PROCESS^ECXANUR",ECXDESC="NUR Extract Audit Report"
S ECXSAVE("ECXHEAD")="",ECXSAVE("ECXALL")="",ECXSAVE("ECXDIV(")="",ECXSAVE("ECXARRAY(")=""
W !
D DEVICE^ECXUTLA(ECXPGM,ECXDESC,.ECXSAVE)
I ECXSAVE("POP")=1 D Q
.W !!,?5,"Try again later... exiting.",!
.D AUDIT^ECXKILL
I ECXSAVE("ZTSK")=0 D
.K ECXSAVE,ECXPGM,ECXDESC
.D PROCESS^ECXANUR
I IO'=IO(0) D ^%ZISC
D HOME^%ZIS
D AUDIT^ECXKILL
Q
;
PROCESS ;process data in file #727.805
N X,Y,W,DATA,DATE,DIV,IEN,LOC,PAT,BD,BDS,QQFLG,CNT
K ^TMP($J,"ECXAUD")
S (CNT,QQFLG)=0
S ECXEXT=ECXARRAY("EXTRACT"),ECXDEF=ECXARRAY("DEF")
S X=ECXARRAY("START") D ^%DT S ECXSTART=Y S X=ECXARRAY("END") D ^%DT S ECXEND=Y
;get run date in external format
D NOW^%DTC S Y=$E(%,1,12) D DD^%DT S ECXRUN=Y
;get records in date range and ward set
S IEN="" F S IEN=$O(^ECX(727.805,"AC",ECXEXT,IEN)) Q:IEN="" D
.S DATA=^ECX(727.805,IEN,0),DATE=$P(DATA,U,9),LOC=$P(DATA,U,13)
.;convert free text date to fm internal format date
.S $E(DATE,1,2)=$E(DATE,1,2)-17
.Q:$L(DATE)<7 Q:(DATE<ECXSTART) Q:(DATE>ECXEND)
.;if ward is among those selected, then tally nursing data
.I $D(ECXDIV(LOC)) D
..S DIV="",DIV=$O(ECXDIV(LOC,DIV))
..S PAT=$P(DATA,U,10),BD=$P(DATA,U,14)
..I '$D(^TMP($J,"ECXAUD",DIV,LOC,BD,PAT)) S ^TMP($J,"ECXAUD",DIV,LOC,BD,PAT)=0
..S ^(PAT)=^TMP($J,"ECXAUD",DIV,LOC,BD,PAT)+1,CNT=CNT+1
..I $D(ZTQUEUED),(CNT>499),'(CNT#500),$$S^%ZTLOAD S QQFLG=1,ZTSTOP=1 K ZTREQ
;after all extract records processed, get bedsection names for printing
I $D(ZTQUEUED),$$S^%ZTLOAD S ZTSTOP=1 K ZTREQ Q
S IEN=0 F S IEN=$O(^NURSF(213.3,IEN)) Q:+IEN=0 S BDS(IEN)=$P(^NURSF(213.3,IEN,0),U,1)
;print the report
D PRINT
D AUDIT^ECXKILL
Q
;
PRINT ;print the nursing classification data by division and location order
N JJ,SS,LN,NM,BDNM,NLNM,DIV,DIVNM,LOC,PG,QFLG,BTOT,GTOT,STOT,DIR,DIRUT,DTOUT,DUOUT
U IO
I $D(ZTQUEUED),$$S^%ZTLOAD S ZTSTOP=1 K ZTREQ Q
S (QFLG,PG)=0,$P(LN,"-",80)="",DIV=""
F S DIV=$O(ECXDIV("D",DIV)) Q:DIV="" D Q:QFLG
.S DIVNM=$P(ECXDIV("D",DIV),U,2)_" ("_$P(ECXDIV("D",DIV),U,3)_")" D HEADER
.I '$D(^TMP($J,"ECXAUD",DIV)) D Q
..W !!,?3,"No data available for this division.",!!
.F JJ=1:1:5 S GTOT(JJ)=0,GTOT("T")=0
.I $D(^TMP($J,"ECXAUD",DIV)) S LOC="" F S LOC=$O(^TMP($J,"ECXAUD",DIV,LOC)) Q:LOC="" D Q:QFLG
..F JJ=1:1:5 S STOT(JJ)=0,STOT("T")=0
..S NLNM=$P(ECXDIV(LOC,DIV),U,2)_" ("_LOC_")",BD=""
..D:($Y+3>IOSL) HEADER Q:QFLG W !,NLNM
..F S BD=$O(^TMP($J,"ECXAUD",DIV,LOC,BD)) Q:BD="" D Q:QFLG
...F PAT=1:1:5 S TOT(PAT)=+$G(^TMP($J,"ECXAUD",DIV,LOC,BD,PAT))
...S BDNM=BDS(BD),BDNM=$E(BDNM,1,22)_" ("_BD_")",BTOT=0 F JJ=1:1:5 S BTOT=BTOT+TOT(JJ)
...;write the bedsection totals
...D:($Y+3>IOSL) HEADER Q:QFLG
...W !,?3,BDNM,?33,$$RJ^XLFSTR(TOT(1),5," "),?41,$$RJ^XLFSTR(TOT(2),5," "),?50,$$RJ^XLFSTR(TOT(3),5," "),?57,$$RJ^XLFSTR(TOT(4),5," "),?64,$$RJ^XLFSTR(TOT(5),5," "),?74,$$RJ^XLFSTR(BTOT,5," ")
...;increment grand total and subtotal
...F JJ=1:1:5 S GTOT(JJ)=GTOT(JJ)+TOT(JJ),STOT(JJ)=STOT(JJ)+TOT(JJ)
...S GTOT("T")=GTOT("T")+BTOT,STOT("T")=STOT("T")+BTOT
..;write the location subtotals
..D:($Y+3>IOSL) HEADER Q:QFLG W !,?33,$E(LN,1,46)
..D:($Y+3>IOSL) HEADER Q:QFLG W !,"Sub-totals for Location ("_LOC_"):"
..W ?33,$$RJ^XLFSTR(STOT(1),5," "),?41,$$RJ^XLFSTR(STOT(2),5," "),?50,$$RJ^XLFSTR(STOT(3),5," "),?57,$$RJ^XLFSTR(STOT(4),5," "),?64,$$RJ^XLFSTR(STOT(5),5," "),?74,$$RJ^XLFSTR(STOT("T"),5," ")
..D:($Y+3>IOSL) HEADER Q:QFLG W !!
.;write the division grand totals
.D:($Y+3>IOSL) HEADER Q:QFLG W !!,"Grand Totals for "_DIVNM_":"
.W ?33,$$RJ^XLFSTR(GTOT(1),5," "),?41,$$RJ^XLFSTR(GTOT(2),5," "),?50,$$RJ^XLFSTR(GTOT(3),5," "),?57,$$RJ^XLFSTR(GTOT(4),5," "),?64,$$RJ^XLFSTR(GTOT(5),5," "),?74,$$RJ^XLFSTR(GTOT("T"),5," ")
;print the audit descriptive narrative
I $E(IOST)'="C" D
.W @IOF S PG=PG+1
.W !,ECXARRAY("TYPE")_" ("_ECXHEAD_") Extract Audit Report"
.W !,"DSS Extract Log #: "_ECXEXT
.W !,"Date Range of Audit: "_ECXARRAY("START")_" to "_ECXARRAY("END")
.W !,"Report Run Date/Time: "_ECXRUN,?68,"Page: ",PG
.W !!,LN,!!
.S DIC="^ECX(727.1,",DA=ECXARRAY("DEF"),DR="1" D EN^DIQ
I $E(IOST)="C",'QFLG D
.S SS=22-$Y F JJ=1:1:SS W !
.S DIR(0)="E" W ! D ^DIR K DIR
Q
;
N JJ,SS
I $E(IOST)="C" D
.S SS=22-$Y F JJ=1:1:SS W !
.I PG>0 S DIR(0)="E" W ! D ^DIR K DIR S:'Y QFLG=1
Q:QFLG
W:$Y!($E(IOST)="C") @IOF S PG=PG+1
W !,ECXARRAY("TYPE")_" ("_ECXHEAD_") Extract Audit Report"
W !,"DSS Extract Log #: "_ECXARRAY("EXTRACT")
W !,"Date Range of Audit: "_ECXARRAY("START")_" to "_ECXARRAY("END")
W !,"Report Run Date/Time: "_ECXRUN
W !,"Medical Center Division: "_$P(ECXDIV("D",DIV),U,2)_" ("_$P(ECXDIV("D",DIV),U,3)_")",?68,"Page: "_PG
W !!,"Nursing Location",?36,"Patients per Acuity Level (Category)"
W !,?3,"Nursing Bedsection",?37,"I",?44,"II",?52,"III",?60,"IV",?68,"V",?74,"Total"
W !,LN,!
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HECXANUR 6204 printed Nov 22, 2024@17:02:12 Page 2
ECXANUR ;ALB/JAP - NUR Extract Audit Report ;Oct 15, 1997
+1 ;;3.0;DSS EXTRACTS;**8**;Dec 22, 1997
+2 ;
EN ;entry point for NUR extract audit report
+1 NEW %X,%Y,X,Y,DIC,DA,DR,DIQ,DIR
+2 SET ECXERR=0
+3 ;ecxaud=0 for 'extract' audit
+4 SET ECXHEAD="NUR"
SET ECXAUD=0
+5 WRITE !!,"Setup for ",ECXHEAD," Extract Audit Report --",!!
+6 ;select extract
+7 DO AUDIT^ECXUTLA(ECXHEAD,.ECXERR,.ECXARRAY,ECXAUD)
+8 if ECXERR
QUIT
+9 ;determine if facility is multidivisional
+10 SET DIC="^DG(43,"
SET DA=1
SET DR="11;"
SET DIQ="ECX"
SET DIQ(0)="I"
DO EN^DIQ1
+11 IF +ECX(43,1,11,"I")=0
SET ECXALL=1
+12 IF +ECX(43,1,11,"I")=1
Begin DoDot:1
+13 WRITE !!
+14 SET DIR(0)="Y"
SET DIR("A")="Do you want the "_ECXHEAD_" extract audit report for all divisions"
+15 SET DIR("B")="NO"
DO ^DIR
KILL DIR
+16 IF $GET(DIRUT)
SET ECXERR=1
QUIT
+17 ;if y=0 i.e., 'no', then ecxall=0 i.e., 'selected'
+18 SET ECXALL=Y
End DoDot:1
+19 IF ECXERR=1
Begin DoDot:1
+20 WRITE !!,?5,"Try again later... exiting.",!
+21 DO AUDIT^ECXKILL
End DoDot:1
QUIT
+22 ;select divisions/sites; all divisions if ecxall=1
+23 SET X=ECXARRAY("START")
DO ^%DT
SET ECXSTART=Y
SET X=ECXARRAY("END")
DO ^%DT
SET ECXEND=Y
+24 DO NUR^ECXDVSN1(.ECXDIV,ECXALL,.ECXERR)
+25 IF ECXERR=1
Begin DoDot:1
+26 WRITE !!,?5,"Try again later... exiting.",!
+27 DO AUDIT^ECXKILL
End DoDot:1
QUIT
+28 ;determine output device and queue if requested
+29 WRITE !
+30 SET ECXPGM="PROCESS^ECXANUR"
SET ECXDESC="NUR Extract Audit Report"
+31 SET ECXSAVE("ECXHEAD")=""
SET ECXSAVE("ECXALL")=""
SET ECXSAVE("ECXDIV(")=""
SET ECXSAVE("ECXARRAY(")=""
+32 WRITE !
+33 DO DEVICE^ECXUTLA(ECXPGM,ECXDESC,.ECXSAVE)
+34 IF ECXSAVE("POP")=1
Begin DoDot:1
+35 WRITE !!,?5,"Try again later... exiting.",!
+36 DO AUDIT^ECXKILL
End DoDot:1
QUIT
+37 IF ECXSAVE("ZTSK")=0
Begin DoDot:1
+38 KILL ECXSAVE,ECXPGM,ECXDESC
+39 DO PROCESS^ECXANUR
End DoDot:1
+40 IF IO'=IO(0)
DO ^%ZISC
+41 DO HOME^%ZIS
+42 DO AUDIT^ECXKILL
+43 QUIT
+44 ;
PROCESS ;process data in file #727.805
+1 NEW X,Y,W,DATA,DATE,DIV,IEN,LOC,PAT,BD,BDS,QQFLG,CNT
+2 KILL ^TMP($JOB,"ECXAUD")
+3 SET (CNT,QQFLG)=0
+4 SET ECXEXT=ECXARRAY("EXTRACT")
SET ECXDEF=ECXARRAY("DEF")
+5 SET X=ECXARRAY("START")
DO ^%DT
SET ECXSTART=Y
SET X=ECXARRAY("END")
DO ^%DT
SET ECXEND=Y
+6 ;get run date in external format
+7 DO NOW^%DTC
SET Y=$EXTRACT(%,1,12)
DO DD^%DT
SET ECXRUN=Y
+8 ;get records in date range and ward set
+9 SET IEN=""
FOR
SET IEN=$ORDER(^ECX(727.805,"AC",ECXEXT,IEN))
if IEN=""
QUIT
Begin DoDot:1
+10 SET DATA=^ECX(727.805,IEN,0)
SET DATE=$PIECE(DATA,U,9)
SET LOC=$PIECE(DATA,U,13)
+11 ;convert free text date to fm internal format date
+12 SET $EXTRACT(DATE,1,2)=$EXTRACT(DATE,1,2)-17
+13 if $LENGTH(DATE)<7
QUIT
if (DATE<ECXSTART)
QUIT
if (DATE>ECXEND)
QUIT
+14 ;if ward is among those selected, then tally nursing data
+15 IF $DATA(ECXDIV(LOC))
Begin DoDot:2
+16 SET DIV=""
SET DIV=$ORDER(ECXDIV(LOC,DIV))
+17 SET PAT=$PIECE(DATA,U,10)
SET BD=$PIECE(DATA,U,14)
+18 IF '$DATA(^TMP($JOB,"ECXAUD",DIV,LOC,BD,PAT))
SET ^TMP($JOB,"ECXAUD",DIV,LOC,BD,PAT)=0
+19 SET ^(PAT)=^TMP($JOB,"ECXAUD",DIV,LOC,BD,PAT)+1
SET CNT=CNT+1
+20 IF $DATA(ZTQUEUED)
IF (CNT>499)
IF '(CNT#500)
IF $$S^%ZTLOAD
SET QQFLG=1
SET ZTSTOP=1
KILL ZTREQ
End DoDot:2
End DoDot:1
+21 ;after all extract records processed, get bedsection names for printing
+22 IF $DATA(ZTQUEUED)
IF $$S^%ZTLOAD
SET ZTSTOP=1
KILL ZTREQ
QUIT
+23 SET IEN=0
FOR
SET IEN=$ORDER(^NURSF(213.3,IEN))
if +IEN=0
QUIT
SET BDS(IEN)=$PIECE(^NURSF(213.3,IEN,0),U,1)
+24 ;print the report
+25 DO PRINT
+26 DO AUDIT^ECXKILL
+27 QUIT
+28 ;
PRINT ;print the nursing classification data by division and location order
+1 NEW JJ,SS,LN,NM,BDNM,NLNM,DIV,DIVNM,LOC,PG,QFLG,BTOT,GTOT,STOT,DIR,DIRUT,DTOUT,DUOUT
+2 USE IO
+3 IF $DATA(ZTQUEUED)
IF $$S^%ZTLOAD
SET ZTSTOP=1
KILL ZTREQ
QUIT
+4 SET (QFLG,PG)=0
SET $PIECE(LN,"-",80)=""
SET DIV=""
+5 FOR
SET DIV=$ORDER(ECXDIV("D",DIV))
if DIV=""
QUIT
Begin DoDot:1
+6 SET DIVNM=$PIECE(ECXDIV("D",DIV),U,2)_" ("_$PIECE(ECXDIV("D",DIV),U,3)_")"
DO HEADER
+7 IF '$DATA(^TMP($JOB,"ECXAUD",DIV))
Begin DoDot:2
+8 WRITE !!,?3,"No data available for this division.",!!
End DoDot:2
QUIT
+9 FOR JJ=1:1:5
SET GTOT(JJ)=0
SET GTOT("T")=0
+10 IF $DATA(^TMP($JOB,"ECXAUD",DIV))
SET LOC=""
FOR
SET LOC=$ORDER(^TMP($JOB,"ECXAUD",DIV,LOC))
if LOC=""
QUIT
Begin DoDot:2
+11 FOR JJ=1:1:5
SET STOT(JJ)=0
SET STOT("T")=0
+12 SET NLNM=$PIECE(ECXDIV(LOC,DIV),U,2)_" ("_LOC_")"
SET BD=""
+13 if ($Y+3>IOSL)
DO HEADER
if QFLG
QUIT
WRITE !,NLNM
+14 FOR
SET BD=$ORDER(^TMP($JOB,"ECXAUD",DIV,LOC,BD))
if BD=""
QUIT
Begin DoDot:3
+15 FOR PAT=1:1:5
SET TOT(PAT)=+$GET(^TMP($JOB,"ECXAUD",DIV,LOC,BD,PAT))
+16 SET BDNM=BDS(BD)
SET BDNM=$EXTRACT(BDNM,1,22)_" ("_BD_")"
SET BTOT=0
FOR JJ=1:1:5
SET BTOT=BTOT+TOT(JJ)
+17 ;write the bedsection totals
+18 if ($Y+3>IOSL)
DO HEADER
if QFLG
QUIT
+19 WRITE !,?3,BDNM,?33,$$RJ^XLFSTR(TOT(1),5," "),?41,$$RJ^XLFSTR(TOT(2),5," "),?50,$$RJ^XLFSTR(TOT(3),5," "),?57,$$RJ^XLFSTR(TOT(4),5," "),?64,$$RJ^XLFSTR(TOT(5),5," "),?74,$$RJ^XLFSTR(BTOT,5," ")
+20 ;increment grand total and subtotal
+21 FOR JJ=1:1:5
SET GTOT(JJ)=GTOT(JJ)+TOT(JJ)
SET STOT(JJ)=STOT(JJ)+TOT(JJ)
+22 SET GTOT("T")=GTOT("T")+BTOT
SET STOT("T")=STOT("T")+BTOT
End DoDot:3
if QFLG
QUIT
+23 ;write the location subtotals
+24 if ($Y+3>IOSL)
DO HEADER
if QFLG
QUIT
WRITE !,?33,$EXTRACT(LN,1,46)
+25 if ($Y+3>IOSL)
DO HEADER
if QFLG
QUIT
WRITE !,"Sub-totals for Location ("_LOC_"):"
+26 WRITE ?33,$$RJ^XLFSTR(STOT(1),5," "),?41,$$RJ^XLFSTR(STOT(2),5," "),?50,$$RJ^XLFSTR(STOT(3),5," "),?57,$$RJ^XLFSTR(STOT(4),5," "),?64,$$RJ^XLFSTR(STOT(5),5," "),?74,$$RJ^XLFSTR(STOT("T"),5," ")
+27 if ($Y+3>IOSL)
DO HEADER
if QFLG
QUIT
WRITE !!
End DoDot:2
if QFLG
QUIT
+28 ;write the division grand totals
+29 if ($Y+3>IOSL)
DO HEADER
if QFLG
QUIT
WRITE !!,"Grand Totals for "_DIVNM_":"
+30 WRITE ?33,$$RJ^XLFSTR(GTOT(1),5," "),?41,$$RJ^XLFSTR(GTOT(2),5," "),?50,$$RJ^XLFSTR(GTOT(3),5," "),?57,$$RJ^XLFSTR(GTOT(4),5," "),?64,$$RJ^XLFSTR(GTOT(5),5," "),?74,$$RJ^XLFSTR(GTOT("T"),5," ")
End DoDot:1
if QFLG
QUIT
+31 ;print the audit descriptive narrative
+32 IF $EXTRACT(IOST)'="C"
Begin DoDot:1
+33 WRITE @IOF
SET PG=PG+1
+34 WRITE !,ECXARRAY("TYPE")_" ("_ECXHEAD_") Extract Audit Report"
+35 WRITE !,"DSS Extract Log #: "_ECXEXT
+36 WRITE !,"Date Range of Audit: "_ECXARRAY("START")_" to "_ECXARRAY("END")
+37 WRITE !,"Report Run Date/Time: "_ECXRUN,?68,"Page: ",PG
+38 WRITE !!,LN,!!
+39 SET DIC="^ECX(727.1,"
SET DA=ECXARRAY("DEF")
SET DR="1"
DO EN^DIQ
End DoDot:1
+40 IF $EXTRACT(IOST)="C"
IF 'QFLG
Begin DoDot:1
+41 SET SS=22-$Y
FOR JJ=1:1:SS
WRITE !
+42 SET DIR(0)="E"
WRITE !
DO ^DIR
KILL DIR
End DoDot:1
+43 QUIT
+44 ;
+1 NEW JJ,SS
+2 IF $EXTRACT(IOST)="C"
Begin DoDot:1
+3 SET SS=22-$Y
FOR JJ=1:1:SS
WRITE !
+4 IF PG>0
SET DIR(0)="E"
WRITE !
DO ^DIR
KILL DIR
if 'Y
SET QFLG=1
End DoDot:1
+5 if QFLG
QUIT
+6 if $Y!($EXTRACT(IOST)="C")
WRITE @IOF
SET PG=PG+1
+7 WRITE !,ECXARRAY("TYPE")_" ("_ECXHEAD_") Extract Audit Report"
+8 WRITE !,"DSS Extract Log #: "_ECXARRAY("EXTRACT")
+9 WRITE !,"Date Range of Audit: "_ECXARRAY("START")_" to "_ECXARRAY("END")
+10 WRITE !,"Report Run Date/Time: "_ECXRUN
+11 WRITE !,"Medical Center Division: "_$PIECE(ECXDIV("D",DIV),U,2)_" ("_$PIECE(ECXDIV("D",DIV),U,3)_")",?68,"Page: "_PG
+12 WRITE !!,"Nursing Location",?36,"Patients per Acuity Level (Category)"
+13 WRITE !,?3,"Nursing Bedsection",?37,"I",?44,"II",?52,"III",?60,"IV",?68,"V",?74,"Total"
+14 WRITE !,LN,!
+15 QUIT