ECXATRT ;ALB/JAP - TRT Extract Audit Report ;11/15/17 10:30
;;3.0;DSS EXTRACTS;**1,6,8,107,105,149,169**;Dec 22, 1997;Build 2
;
EN ;entry point for TRT extract audit report
N %X,%Y,X,Y,DIC,DA,DR,DIQ,DIR,ECXPORT,RCNT ;149
S ECXERR=0
;ecxaud=0 for 'extract' audit
S ECXHEAD="TRT",ECXAUD=0
W !!,"Setup for ",ECXHEAD," Extract Audit Report --",!!
;select extract
D AUDIT^ECXUTLA(ECXHEAD,.ECXERR,.ECXARRAY,ECXAUD)
Q:ECXERR
;currently, this extract does not capture divisional data
S ECXALL=1
D TRT^ECXDVSN(.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^ECXATRT",ECXDESC="TRT Extract Audit Report"
S ECXSAVE("ECXHEAD")="",ECXSAVE("ECXALL")="",ECXSAVE("ECXDIV(")="",ECXSAVE("ECXARRAY(")=""
S ECXPORT=$$EXPORT^ECXUTL1 Q:ECXPORT=-1 I $G(ECXPORT) D Q ;149 Section added
.K ^TMP($J,"ECXPORT")
.S ^TMP($J,"ECXPORT",0)="EXTRACT LOG #^DSS SITE^SERVICE^SPECIALTY (DSS CODE)^FACILITY TREATING SPECIALTY^# OF LOSSES",RCNT=1
.D PROCESS
.D EXPDISP^ECXUTL1
.D AUDIT^ECXKILL
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^ECXATRT
I IO'=IO(0) D ^%ZISC
D HOME^%ZIS
D AUDIT^ECXKILL
Q
;
PROCESS ;process data in file #727.817
N X,Y,W,DATA,DATE,DIV,IEN,TS,SPEC,FTS,FTSNM,SERV,ECX,QQFLG,CNT,A1,A2,NUM,MN,NEWFTS,NEWSPEC
K ^TMP($J,"ECXAUD"),^TMP($J,"ECXSPEC")
S (QQFLG,CNT)=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
;set up the specialty array for site/division
I $D(ZTQUEUED),$$S^%ZTLOAD S ZTSTOP=1 K ZTREQ Q
S DIV="" F S DIV=$O(ECXDIV(DIV)) Q:DIV="" D
.S DIC="^DIC(42.4,",DR=".01;3",DIQ(0)="E",DIQ="ECX"
.S SPEC="" F S SPEC=$O(^DIC(42.4,"B",SPEC)) Q:SPEC="" S TS=$O(^(SPEC,0)) D
..K ECX S DA=TS D EN^DIQ1
..S SPEC=$G(ECX(42.4,TS,.01,"E")),SERV=$G(ECX(42.4,TS,3,"E")) S:SERV="" SERV="Unknown"
..S ^TMP($J,"ECXSPEC",DIV,TS)=0_U_SERV_U_SPEC,NUM(TS)=0
;set up the specialty to facility treating specialty conversion array;
;determine if active between ecxstart and ecxend;
;ignore if facility treating specialty not active within date range of report;
S DIC="^DIC(45.7,",DR=".01;1",DIQ(0)="I",DIQ="ECX"
S FTSNM="" F S FTSNM=$O(^DIC(45.7,"B",FTSNM)) Q:FTSNM="" S FTS=$O(^(FTSNM,0)) D
.K ECX S DA=FTS D EN^DIQ1
.S FTSNM=$G(ECX(45.7,FTS,.01,"I")),TS=$G(ECX(45.7,FTS,1,"I"))
.Q:TS=""
.S A1=$$ACTIVE^DGACT(45.7,FTS,ECXSTART),A2=$$ACTIVE^DGACT(45.7,FTS,ECXEND)
.Q:A1=0&(A2=0)
.;num(ts) will hold the number of active facility treat. specialties (file #45.7) associated
.;with this national specialty (file #42.4).
.I '$D(NUM(TS)) S NUM(TS)=0
.S ^TMP($J,"ECXTS",TS,FTS)=FTSNM,^TMP($J,"ECXREVTS",FTS)=TS,NUM(TS)=NUM(TS)+1
;get extract records in date range
S IEN="" F S IEN=$O(^ECX(727.817,"AC",ECXEXT,IEN)) Q:IEN="" D Q:QQFLG
.S DATA=^ECX(727.817,IEN,0),DATE=$P(DATA,U,9),DIV="" ;169 ,DIV=$P(DATA,U,4)
.;169 4th piece (Facility) is populated starting with patch 169, however, we want all data to be counted in one divisision so it's defaulted to 1
.S:DIV="" DIV=1
.;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)
.I $D(ECXDIV(DIV)) D
..;ts is the old specialty, newfts is the new facility treat. spec. for the movement date;
..;after patch #1 'losing treating specialty los' field (#17) is non-null only for actual specialty changes;
..;so should be able to distinguish true ts changes from provider-only changes;
..;although it will still be possible that old and new specialty are the same, but facility
..;treat. spec. was changed, but we've lost that info in the extract.
..;
..;filter out those records which are definitely provider-only changes;
..;these are the records that have 'losing treating specialty los' which is null;
..;but for extracts done prior to patch #1, still need to compare old & new specialty.
..;
..;convert 15th and 16th piece from PTF code back to Specialty
..;ECX*3.0*107
..;
..N ECXTS,NEWTS
..S ECXTS=$P(DATA,U,15) I ECXTS'="" S ECXTS=$O(^DIC(42.4,"C",$G(ECXTS),0)),$P(DATA,U,15)=ECXTS
..S ECXTS=$P(DATA,U,16) I ECXTS'="" S ECXTS=$O(^DIC(42.4,"C",$G(ECXTS),0)),$P(DATA,U,16)=ECXTS
..S NEWTS=$P(DATA,U,15),TS=$P(DATA,U,16),LOS=$P(DATA,U,17)
..;leaving this next line in here for v3.0 extracts done prior to patch #1
..Q:(NUM(+TS)=1)&(NEWTS=TS)
..Q:LOS=""
..S $P(^(TS),U,1)=$P(^TMP($J,"ECXSPEC",DIV,TS),U,1)+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, arrange by service and specialty;
;total can only be associated with specialty, not facility treating specialty;
;include specialty only if total loss is non-zero
I $D(ZTQUEUED),$$S^%ZTLOAD S ZTSTOP=1 K ZTREQ Q
S DIV="" F S DIV=$O(ECXDIV(DIV)) Q:DIV="" I $D(^TMP($J,"ECXSPEC",DIV)) D
.S TS="" F S TS=$O(^TMP($J,"ECXSPEC",DIV,TS)) Q:TS="" D
..S TOT=+$P(^TMP($J,"ECXSPEC",DIV,TS),U,1) I TOT>0 D
...S SERV=$P(^(TS),U,2),SPEC=$P(^(TS),U,3)
...S ^TMP($J,"ECXAUD",DIV,SERV,SPEC)=TOT_U_TS
;print the report
D PRINT
I $G(ECXPORT) Q ;149
D AUDIT^ECXKILL
Q
;
PRINT ;print trt data by site, by service, by specialty
N JJ,SS,LN,P,DIV,DIVNM,GTOT,SVCTOT,PG,QFLG,DIR,DIRUT,DTOUT,DUOUT,FIRST ;149
U IO
I $D(ZTQUEUED),$$S^%ZTLOAD S ZTSTOP=1 K ZTREQ Q
S (QFLG,PG)=0,$P(LN,"-",80)=""
;division associated with the treat. spec. change is not actually known; division is dss site
S DIV="" S DIV=$O(ECXDIV(DIV)) Q:DIV="" S GTOT=0
I '$G(ECXPORT) D HEADER ;149
I '$D(^TMP($J,"ECXAUD",DIV)) D Q
.I $G(ECXPORT) S ^TMP($J,"ECXPORT",RCNT)=ECXEXT_U_$P(ECXDIV(DIV),U,2)_" ("_$P(ECXDIV(DIV),U,3)_")"_U_"No data available for this DSS Site",RCNT=RCNT+1 Q ;149
.W !!,?5,"No data available for this DSS Site.",!!
I $D(^TMP($J,"ECXAUD",DIV)) S SERV="" F S SERV=$O(^TMP($J,"ECXAUD",DIV,SERV)) Q:SERV="" D Q:QFLG
.S SVCTOT=0
.;write the service name
.I '$G(ECXPORT) D:($Y+3>IOSL) HEADER Q:QFLG W !,SERV ;149
.S SPEC="" F S SPEC=$O(^TMP($J,"ECXAUD",DIV,SERV,SPEC)) Q:SPEC="" D Q:QFLG
..;write the specialty name and total
..S TOT=$P(^TMP($J,"ECXAUD",DIV,SERV,SPEC),U,1),TS=$P(^(SPEC),U,2)
..I $G(ECXPORT) S ^TMP($J,"ECXPORT",RCNT)=ECXEXT_U_$P(ECXDIV(DIV),U,2)_" ("_$P(ECXDIV(DIV),U,3)_")"_U_SERV_U_SPEC_" ("_TS_")"_"^^"_TOT,RCNT=RCNT+1 ;149
..I '$G(ECXPORT) W ?22,$E(SPEC,1,30)_" ("_TS_")",?68,$$RJ^XLFSTR(TOT,5," "),! ;149
..S SVCTOT=SVCTOT+TOT,GTOT=GTOT+TOT
..S FIRST=1 ;149
..S FTS="" F S FTS=$O(^TMP($J,"ECXTS",TS,FTS)) Q:FTS="" D Q:QFLG
...S FTSNM=^TMP($J,"ECXTS",TS,FTS)
...I $G(ECXPORT),FIRST S $P(^TMP($J,"ECXPORT",(RCNT-1)),U,5)=FTSNM,FIRST=0 Q ;149 For first treating specialty, put it on same line as the "total" line
...I $G(ECXPORT) S ^TMP($J,"ECXPORT",RCNT)=ECXEXT_U_$P(ECXDIV(DIV),U,2)_" ("_$P(ECXDIV(DIV),U,3)_")"_U_SERV_U_SPEC_" ("_TS_")"_U_FTSNM,RCNT=RCNT+1 Q ;149
...D:($Y+3>IOSL) HEADER Q:QFLG W ?25,$E(FTSNM,1,30),!
.;write the service subtotal
.Q:QFLG
.I $G(ECXPORT) S ^TMP($J,"ECXPORT",RCNT)="^",RCNT=RCNT+1,^TMP($J,"ECXPORT",RCNT)="^^Total for "_SERV_"^^^"_SVCTOT,RCNT=RCNT+1,^TMP($J,"ECXPORT",RCNT)="^",RCNT=RCNT+1 Q ;149
.W ?22,$E(LN,1,54),!
.D:($Y+3>IOSL) HEADER Q:QFLG W "Total for "_SERV_":",?68,$$RJ^XLFSTR(SVCTOT,5," "),!
;write the grandtotal for all services at facility
I $G(ECXPORT) S ^TMP($J,"ECXPORT",RCNT)="^^Grand Total for all Services^^^"_GTOT Q ;149
D:($Y+3>IOSL) HEADER Q:QFLG W !!,"Grand Total for all Services:",?68,$$RJ^XLFSTR(GTOT,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",'QFLG D ;149 Quit if user entered "^"
.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 !,"Treating Specialty Change"_" ("_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 !,"DSS Site: "_$P(ECXDIV(DIV),U,2)_" ("_$P(ECXDIV(DIV),U,3)_")",?68,"Page: "_PG
W !!,"Service",?22,"Specialty (DSS Code)",?68,"# of Losses"
W !,?25,"Facility Treating Specialty"
W !,LN,!
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HECXATRT 9143 printed Dec 13, 2024@01:52:14 Page 2
ECXATRT ;ALB/JAP - TRT Extract Audit Report ;11/15/17 10:30
+1 ;;3.0;DSS EXTRACTS;**1,6,8,107,105,149,169**;Dec 22, 1997;Build 2
+2 ;
EN ;entry point for TRT extract audit report
+1 ;149
NEW %X,%Y,X,Y,DIC,DA,DR,DIQ,DIR,ECXPORT,RCNT
+2 SET ECXERR=0
+3 ;ecxaud=0 for 'extract' audit
+4 SET ECXHEAD="TRT"
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 ;currently, this extract does not capture divisional data
+10 SET ECXALL=1
+11 DO TRT^ECXDVSN(.ECXDIV,ECXALL,.ECXERR)
+12 IF ECXERR=1
Begin DoDot:1
+13 WRITE !!,?5,"Try again later... exiting.",!
+14 DO AUDIT^ECXKILL
End DoDot:1
QUIT
+15 ;determine output device and queue if requested
+16 WRITE !
+17 SET ECXPGM="PROCESS^ECXATRT"
SET ECXDESC="TRT Extract Audit Report"
+18 SET ECXSAVE("ECXHEAD")=""
SET ECXSAVE("ECXALL")=""
SET ECXSAVE("ECXDIV(")=""
SET ECXSAVE("ECXARRAY(")=""
+19 ;149 Section added
SET ECXPORT=$$EXPORT^ECXUTL1
if ECXPORT=-1
QUIT
IF $GET(ECXPORT)
Begin DoDot:1
+20 KILL ^TMP($JOB,"ECXPORT")
+21 SET ^TMP($JOB,"ECXPORT",0)="EXTRACT LOG #^DSS SITE^SERVICE^SPECIALTY (DSS CODE)^FACILITY TREATING SPECIALTY^# OF LOSSES"
SET RCNT=1
+22 DO PROCESS
+23 DO EXPDISP^ECXUTL1
+24 DO AUDIT^ECXKILL
End DoDot:1
QUIT
+25 WRITE !
+26 DO DEVICE^ECXUTLA(ECXPGM,ECXDESC,.ECXSAVE)
+27 IF ECXSAVE("POP")=1
Begin DoDot:1
+28 WRITE !!,?5,"Try again later... exiting.",!
+29 DO AUDIT^ECXKILL
End DoDot:1
QUIT
+30 IF ECXSAVE("ZTSK")=0
Begin DoDot:1
+31 KILL ECXSAVE,ECXPGM,ECXDESC
+32 DO PROCESS^ECXATRT
End DoDot:1
+33 IF IO'=IO(0)
DO ^%ZISC
+34 DO HOME^%ZIS
+35 DO AUDIT^ECXKILL
+36 QUIT
+37 ;
PROCESS ;process data in file #727.817
+1 NEW X,Y,W,DATA,DATE,DIV,IEN,TS,SPEC,FTS,FTSNM,SERV,ECX,QQFLG,CNT,A1,A2,NUM,MN,NEWFTS,NEWSPEC
+2 KILL ^TMP($JOB,"ECXAUD"),^TMP($JOB,"ECXSPEC")
+3 SET (QQFLG,CNT)=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 ;set up the specialty array for site/division
+9 IF $DATA(ZTQUEUED)
IF $$S^%ZTLOAD
SET ZTSTOP=1
KILL ZTREQ
QUIT
+10 SET DIV=""
FOR
SET DIV=$ORDER(ECXDIV(DIV))
if DIV=""
QUIT
Begin DoDot:1
+11 SET DIC="^DIC(42.4,"
SET DR=".01;3"
SET DIQ(0)="E"
SET DIQ="ECX"
+12 SET SPEC=""
FOR
SET SPEC=$ORDER(^DIC(42.4,"B",SPEC))
if SPEC=""
QUIT
SET TS=$ORDER(^(SPEC,0))
Begin DoDot:2
+13 KILL ECX
SET DA=TS
DO EN^DIQ1
+14 SET SPEC=$GET(ECX(42.4,TS,.01,"E"))
SET SERV=$GET(ECX(42.4,TS,3,"E"))
if SERV=""
SET SERV="Unknown"
+15 SET ^TMP($JOB,"ECXSPEC",DIV,TS)=0_U_SERV_U_SPEC
SET NUM(TS)=0
End DoDot:2
End DoDot:1
+16 ;set up the specialty to facility treating specialty conversion array;
+17 ;determine if active between ecxstart and ecxend;
+18 ;ignore if facility treating specialty not active within date range of report;
+19 SET DIC="^DIC(45.7,"
SET DR=".01;1"
SET DIQ(0)="I"
SET DIQ="ECX"
+20 SET FTSNM=""
FOR
SET FTSNM=$ORDER(^DIC(45.7,"B",FTSNM))
if FTSNM=""
QUIT
SET FTS=$ORDER(^(FTSNM,0))
Begin DoDot:1
+21 KILL ECX
SET DA=FTS
DO EN^DIQ1
+22 SET FTSNM=$GET(ECX(45.7,FTS,.01,"I"))
SET TS=$GET(ECX(45.7,FTS,1,"I"))
+23 if TS=""
QUIT
+24 SET A1=$$ACTIVE^DGACT(45.7,FTS,ECXSTART)
SET A2=$$ACTIVE^DGACT(45.7,FTS,ECXEND)
+25 if A1=0&(A2=0)
QUIT
+26 ;num(ts) will hold the number of active facility treat. specialties (file #45.7) associated
+27 ;with this national specialty (file #42.4).
+28 IF '$DATA(NUM(TS))
SET NUM(TS)=0
+29 SET ^TMP($JOB,"ECXTS",TS,FTS)=FTSNM
SET ^TMP($JOB,"ECXREVTS",FTS)=TS
SET NUM(TS)=NUM(TS)+1
End DoDot:1
+30 ;get extract records in date range
+31 SET IEN=""
FOR
SET IEN=$ORDER(^ECX(727.817,"AC",ECXEXT,IEN))
if IEN=""
QUIT
Begin DoDot:1
+32 ;169 ,DIV=$P(DATA,U,4)
SET DATA=^ECX(727.817,IEN,0)
SET DATE=$PIECE(DATA,U,9)
SET DIV=""
+33 ;169 4th piece (Facility) is populated starting with patch 169, however, we want all data to be counted in one divisision so it's defaulted to 1
+34 if DIV=""
SET DIV=1
+35 ;convert free text date to fm internal format date
+36 SET $EXTRACT(DATE,1,2)=$EXTRACT(DATE,1,2)-17
+37 if $LENGTH(DATE)<7
QUIT
if (DATE<ECXSTART)
QUIT
if (DATE>ECXEND)
QUIT
+38 IF $DATA(ECXDIV(DIV))
Begin DoDot:2
+39 ;ts is the old specialty, newfts is the new facility treat. spec. for the movement date;
+40 ;after patch #1 'losing treating specialty los' field (#17) is non-null only for actual specialty changes;
+41 ;so should be able to distinguish true ts changes from provider-only changes;
+42 ;although it will still be possible that old and new specialty are the same, but facility
+43 ;treat. spec. was changed, but we've lost that info in the extract.
+44 ;
+45 ;filter out those records which are definitely provider-only changes;
+46 ;these are the records that have 'losing treating specialty los' which is null;
+47 ;but for extracts done prior to patch #1, still need to compare old & new specialty.
+48 ;
+49 ;convert 15th and 16th piece from PTF code back to Specialty
+50 ;ECX*3.0*107
+51 ;
+52 NEW ECXTS,NEWTS
+53 SET ECXTS=$PIECE(DATA,U,15)
IF ECXTS'=""
SET ECXTS=$ORDER(^DIC(42.4,"C",$GET(ECXTS),0))
SET $PIECE(DATA,U,15)=ECXTS
+54 SET ECXTS=$PIECE(DATA,U,16)
IF ECXTS'=""
SET ECXTS=$ORDER(^DIC(42.4,"C",$GET(ECXTS),0))
SET $PIECE(DATA,U,16)=ECXTS
+55 SET NEWTS=$PIECE(DATA,U,15)
SET TS=$PIECE(DATA,U,16)
SET LOS=$PIECE(DATA,U,17)
+56 ;leaving this next line in here for v3.0 extracts done prior to patch #1
+57 if (NUM(+TS)=1)&(NEWTS=TS)
QUIT
+58 if LOS=""
QUIT
+59 SET $PIECE(^(TS),U,1)=$PIECE(^TMP($JOB,"ECXSPEC",DIV,TS),U,1)+1
SET CNT=CNT+1
+60 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
if QQFLG
QUIT
+61 ;after all extract records processed, arrange by service and specialty;
+62 ;total can only be associated with specialty, not facility treating specialty;
+63 ;include specialty only if total loss is non-zero
+64 IF $DATA(ZTQUEUED)
IF $$S^%ZTLOAD
SET ZTSTOP=1
KILL ZTREQ
QUIT
+65 SET DIV=""
FOR
SET DIV=$ORDER(ECXDIV(DIV))
if DIV=""
QUIT
IF $DATA(^TMP($JOB,"ECXSPEC",DIV))
Begin DoDot:1
+66 SET TS=""
FOR
SET TS=$ORDER(^TMP($JOB,"ECXSPEC",DIV,TS))
if TS=""
QUIT
Begin DoDot:2
+67 SET TOT=+$PIECE(^TMP($JOB,"ECXSPEC",DIV,TS),U,1)
IF TOT>0
Begin DoDot:3
+68 SET SERV=$PIECE(^(TS),U,2)
SET SPEC=$PIECE(^(TS),U,3)
+69 SET ^TMP($JOB,"ECXAUD",DIV,SERV,SPEC)=TOT_U_TS
End DoDot:3
End DoDot:2
End DoDot:1
+70 ;print the report
+71 DO PRINT
+72 ;149
IF $GET(ECXPORT)
QUIT
+73 DO AUDIT^ECXKILL
+74 QUIT
+75 ;
PRINT ;print trt data by site, by service, by specialty
+1 ;149
NEW JJ,SS,LN,P,DIV,DIVNM,GTOT,SVCTOT,PG,QFLG,DIR,DIRUT,DTOUT,DUOUT,FIRST
+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)=""
+5 ;division associated with the treat. spec. change is not actually known; division is dss site
+6 SET DIV=""
SET DIV=$ORDER(ECXDIV(DIV))
if DIV=""
QUIT
SET GTOT=0
+7 ;149
IF '$GET(ECXPORT)
DO HEADER
+8 IF '$DATA(^TMP($JOB,"ECXAUD",DIV))
Begin DoDot:1
+9 ;149
IF $GET(ECXPORT)
SET ^TMP($JOB,"ECXPORT",RCNT)=ECXEXT_U_$PIECE(ECXDIV(DIV),U,2)_" ("_$PIECE(ECXDIV(DIV),U,3)_")"_U_"No data available for this DSS Site"
SET RCNT=RCNT+1
QUIT
+10 WRITE !!,?5,"No data available for this DSS Site.",!!
End DoDot:1
QUIT
+11 IF $DATA(^TMP($JOB,"ECXAUD",DIV))
SET SERV=""
FOR
SET SERV=$ORDER(^TMP($JOB,"ECXAUD",DIV,SERV))
if SERV=""
QUIT
Begin DoDot:1
+12 SET SVCTOT=0
+13 ;write the service name
+14 ;149
IF '$GET(ECXPORT)
if ($Y+3>IOSL)
DO HEADER
if QFLG
QUIT
WRITE !,SERV
+15 SET SPEC=""
FOR
SET SPEC=$ORDER(^TMP($JOB,"ECXAUD",DIV,SERV,SPEC))
if SPEC=""
QUIT
Begin DoDot:2
+16 ;write the specialty name and total
+17 SET TOT=$PIECE(^TMP($JOB,"ECXAUD",DIV,SERV,SPEC),U,1)
SET TS=$PIECE(^(SPEC),U,2)
+18 ;149
IF $GET(ECXPORT)
SET ^TMP($JOB,"ECXPORT",RCNT)=ECXEXT_U_$PIECE(ECXDIV(DIV),U,2)_" ("_$PIECE(ECXDIV(DIV),U,3)_")"_U_SERV_U_SPEC_" ("_TS_")"_"^^"_TOT
SET RCNT=RCNT+1
+19 ;149
IF '$GET(ECXPORT)
WRITE ?22,$EXTRACT(SPEC,1,30)_" ("_TS_")",?68,$$RJ^XLFSTR(TOT,5," "),!
+20 SET SVCTOT=SVCTOT+TOT
SET GTOT=GTOT+TOT
+21 ;149
SET FIRST=1
+22 SET FTS=""
FOR
SET FTS=$ORDER(^TMP($JOB,"ECXTS",TS,FTS))
if FTS=""
QUIT
Begin DoDot:3
+23 SET FTSNM=^TMP($JOB,"ECXTS",TS,FTS)
+24 ;149 For first treating specialty, put it on same line as the "total" line
IF $GET(ECXPORT)
IF FIRST
SET $PIECE(^TMP($JOB,"ECXPORT",(RCNT-1)),U,5)=FTSNM
SET FIRST=0
QUIT
+25 ;149
IF $GET(ECXPORT)
SET ^TMP($JOB,"ECXPORT",RCNT)=ECXEXT_U_$PIECE(ECXDIV(DIV),U,2)_" ("_$PIECE(ECXDIV(DIV),U,3)_")"_U_SERV_U_SPEC_" ("_TS_")"_U_FTSNM
SET RCNT=RCNT+1
QUIT
+26 if ($Y+3>IOSL)
DO HEADER
if QFLG
QUIT
WRITE ?25,$EXTRACT(FTSNM,1,30),!
End DoDot:3
if QFLG
QUIT
End DoDot:2
if QFLG
QUIT
+27 ;write the service subtotal
+28 if QFLG
QUIT
+29 ;149
IF $GET(ECXPORT)
SET ^TMP($JOB,"ECXPORT",RCNT)="^"
SET RCNT=RCNT+1
SET ^TMP($JOB,"ECXPORT",RCNT)="^^Total for "_SERV_"^^^"_SVCTOT
SET RCNT=RCNT+1
SET ^TMP($JOB,"ECXPORT",RCNT)="^"
SET RCNT=RCNT+1
QUIT
+30 WRITE ?22,$EXTRACT(LN,1,54),!
+31 if ($Y+3>IOSL)
DO HEADER
if QFLG
QUIT
WRITE "Total for "_SERV_":",?68,$$RJ^XLFSTR(SVCTOT,5," "),!
End DoDot:1
if QFLG
QUIT
+32 ;write the grandtotal for all services at facility
+33 ;149
IF $GET(ECXPORT)
SET ^TMP($JOB,"ECXPORT",RCNT)="^^Grand Total for all Services^^^"_GTOT
QUIT
+34 if ($Y+3>IOSL)
DO HEADER
if QFLG
QUIT
WRITE !!,"Grand Total for all Services:",?68,$$RJ^XLFSTR(GTOT,5," ")
+35 ;print the audit descriptive narrative
+36 IF $EXTRACT(IOST)'="C"
Begin DoDot:1
+37 WRITE @IOF
SET PG=PG+1
+38 WRITE !,ECXARRAY("TYPE")_" ("_ECXHEAD_") Extract Audit Report"
+39 WRITE !,"DSS Extract Log #: "_ECXEXT
+40 WRITE !,"Date Range of Audit: "_ECXARRAY("START")_" to "_ECXARRAY("END")
+41 WRITE !,"Report Run Date/Time: "_ECXRUN,?68,"Page: ",PG
+42 WRITE !!,LN,!!
+43 SET DIC="^ECX(727.1,"
SET DA=ECXARRAY("DEF")
SET DR="1"
DO EN^DIQ
End DoDot:1
+44 IF $EXTRACT(IOST)="C"
IF 'QFLG
Begin DoDot:1
+45 SET SS=22-$Y
FOR JJ=1:1:SS
WRITE !
+46 SET DIR(0)="E"
WRITE !
DO ^DIR
KILL DIR
End DoDot:1
+47 QUIT
+48 ;
+1 NEW JJ,SS
+2 ;149 Quit if user entered "^"
IF $EXTRACT(IOST)="C"
IF 'QFLG
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 ;W !,ECXARRAY("TYPE")_" ("_ECXHEAD_") Extract Audit Report"
+8 WRITE !,"Treating Specialty Change"_" ("_ECXHEAD_") Extract Audit Report"
+9 WRITE !,"DSS Extract Log #: "_ECXARRAY("EXTRACT")
+10 WRITE !,"Date Range of Audit: "_ECXARRAY("START")_" to "_ECXARRAY("END")
+11 WRITE !,"Report Run Date/Time: "_ECXRUN
+12 WRITE !,"DSS Site: "_$PIECE(ECXDIV(DIV),U,2)_" ("_$PIECE(ECXDIV(DIV),U,3)_")",?68,"Page: "_PG
+13 WRITE !!,"Service",?22,"Specialty (DSS Code)",?68,"# of Losses"
+14 WRITE !,?25,"Facility Treating Specialty"
+15 WRITE !,LN,!
+16 QUIT