ECXRACPT ;ALB/DAN - Radiology extract invalid CPT report ;7/25/18 14:29
;;3.0;DSS EXTRACTS;**170**;Dec 22, 1997;Build 12
EN ;entry point from menu option
N ECXPORT,CNT,ECXHEAD,ECXERR,ECXARRAY,ECXAUD,ECXDIV,ECXALL,ECXDESC,ECXPGM,ECXSAVE,D0
W @IOF,!!,"Radiology (RAD) Extract CPT Code Audit",!!
;ecxaud=1 stops user from being able to select a date range
S ECXHEAD="RAD",ECXAUD=1
;select extract
D AUDIT^ECXUTLA(ECXHEAD,.ECXERR,.ECXARRAY,ECXAUD)
I ECXERR D AUDIT^ECXKILL Q
;select all radiology sites/divisions
S ECXALL=1 D RAD^ECXDVSN2(.ECXDIV,ECXALL,.ECXERR)
I ECXERR D AUDIT^ECXKILL Q
S ECXPORT=$$EXPORT^ECXUTL1 Q:ECXPORT=-1 I $G(ECXPORT) D Q
.K ^TMP($J,"ECXPORT")
.S ^TMP($J,"ECXPORT",0)="EXTRACT LOG #^DIVISION/SITE^IMAGING TYPE (FEEDER LOCATION)^PROCEDURE DATE^FEEDER KEY^PROCEDURE^PATIENT DFN",CNT=1
.D PROCESS
.D EXPDISP^ECXUTL1
.D AUDIT^ECXKILL
W !!
S ECXPGM="PROCESS^ECXRACPT",ECXDESC="Radiology Extract Invalid CPT Report"
S ECXSAVE("ECXHEAD")="",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
I IO'=IO(0) D ^%ZISC
D HOME^%ZIS
D AUDIT^ECXKILL
Q
;
PROCESS ;queued entry
N J,X,Y,PG,DIV,EC,ECFK,ECFL,QFLG,TYPE,TYPENMN,DIQ,DR,DA,DIR,DIRUT,DTOUT,DUOUT,CPT,DAY,%DT,ECXRUN,ECX,DIC,ECXEXT,ECXDEF,DATA,SEQ,ECXP
K ^TMP($J,"ECXCPT")
S ECXEXT=ECXARRAY("EXTRACT"),ECXDEF=ECXARRAY("DEF")
S (QFLG,PG)=0
;get run date in external format
S ECXRUN=$$FMTE^XLFDT($E($$NOW^XLFDT,1,12))
;setup array of imaging types
S TYPE=0 F S TYPE=$O(^RA(79.2,TYPE)) Q:+TYPE<1 D
.K ECX S DIC="^RA(79.2,",DR=".01;3",DIQ="ECX",DIQ(0)="I",DA=TYPE D EN^DIQ1
.S TYPE(TYPE)=ECX(79.2,TYPE,.01,"I")_U_ECX(79.2,TYPE,3,"I")
;process the extract records
S J="" F S J=$O(^ECX(727.814,"AC",ECXEXT,J)) Q:'J I $D(^ECX(727.814,J,0)) S EC=^(0),DIV=$P(EC,U,4),ECFL=DIV_"-"_$P(EC,U,21) D
.S ECFK=$P(EC,U,10),ECXP=$P(EC,U,11)
.S CPT=$E(ECFK,1,5) ;Get just CPT code from the CPT Code and modifier info in ECFK
.S DAY=$$ECXDATEX^ECXUTL($P(EC,U,9)) ;Convert DSS to readable date
.S X=DAY,%DT="X" D ^%DT S DAY=Y ;Convert readable date to FM date
.I $$STATCHK^ICPTAPIU(CPT,DAY) Q ;If CPT code was valid on this date, skip it
.S ^TMP($J,"ECXCPT",DIV,ECFL,J)=DAY_U_ECXP_U_$$GET1^DIQ(71,$P(EC,U,11),.01)_U_$P(EC,U,5)
.Q
;
;Print/export report
U IO
I '$G(ECXPORT) I '$D(^TMP($J,"ECXCPT")) S DIV=0 D HEADER W !,"No data found." Q
S DIV="" F S DIV=$O(^TMP($J,"ECXCPT",DIV)) Q:DIV=""!(QFLG) D
.D:'$G(ECXPORT) HEADER
.S ECFL="" F S ECFL=$O(^TMP($J,"ECXCPT",DIV,ECFL)) Q:ECFL=""!(QFLG) S TYPE=+$P(ECFL,"-",2) D
..S TYPENMN=$E($P($G(TYPE(TYPE)),U),1,18)
..S SEQ="" F S SEQ=$O(^TMP($J,"ECXCPT",DIV,ECFL,SEQ)) Q:SEQ=""!(QFLG) D
...I '$G(ECXPORT) D:($Y+3>IOSL) HEADER Q:QFLG
...S DATA=^TMP($J,"ECXCPT",DIV,ECFL,SEQ)
...I $G(ECXPORT) D Q
....S ^TMP($J,"ECXPORT",CNT)=ECXEXT_U_$P($G(ECXDIV(DIV)),U,2)_"("_$P($G(ECXDIV(DIV)),U)_")"_U_TYPENMN_" ("_ECFL_")"
....S ^TMP($J,"ECXPORT",CNT)=^TMP($J,"ECXPORT",CNT)_U_$TR($$FMTE^XLFDT($P(DATA,U),"2F")," ",0)_U_$P(DATA,U,2)_U_$P(DATA,U,3)_U_$P(DATA,U,4),CNT=CNT+1 Q
...W TYPENMN," (",ECFL,")"
...W !,?3,$P(DATA,U,2),?11,$E($P(DATA,U,3),1,45),?58,$TR($$FMTE^XLFDT($P(DATA,U),"2F")," ",0),?69,$P(DATA,U,4),!
...Q
..Q
.Q
Q
;
N JJ,SS,LN
S $P(LN,"-",80)="-"
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 !,"Radiology (RAD) Extract CPT Code Audit"
W !,"DSS Extract Log #: "_ECXARRAY("EXTRACT")
W !,"Date Range of Audit: "_ECXARRAY("START")_" to "_ECXARRAY("END")
W !,"Report Run Date/Time: "_ECXRUN
I $D(ECXDIV(DIV)) W !,"Division/Site: "_$P(ECXDIV(DIV),U,2)_" ("_DIV_")",?68,"Page: "_PG
I '$D(ECXDIV(DIV)) W !,"Division/Site: "_"Unknown",?68,"Page: "_PG
W !!,"Imaging Type (Feeder Location)",?58,"Procedure"
W !?3,"FdrKey",?11,"Procedure",?58,"Date",?69,"DFN"
W !,LN,!
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HECXRACPT 4148 printed Dec 13, 2024@01:53:43 Page 2
ECXRACPT ;ALB/DAN - Radiology extract invalid CPT report ;7/25/18 14:29
+1 ;;3.0;DSS EXTRACTS;**170**;Dec 22, 1997;Build 12
EN ;entry point from menu option
+1 NEW ECXPORT,CNT,ECXHEAD,ECXERR,ECXARRAY,ECXAUD,ECXDIV,ECXALL,ECXDESC,ECXPGM,ECXSAVE,D0
+2 WRITE @IOF,!!,"Radiology (RAD) Extract CPT Code Audit",!!
+3 ;ecxaud=1 stops user from being able to select a date range
+4 SET ECXHEAD="RAD"
SET ECXAUD=1
+5 ;select extract
+6 DO AUDIT^ECXUTLA(ECXHEAD,.ECXERR,.ECXARRAY,ECXAUD)
+7 IF ECXERR
DO AUDIT^ECXKILL
QUIT
+8 ;select all radiology sites/divisions
+9 SET ECXALL=1
DO RAD^ECXDVSN2(.ECXDIV,ECXALL,.ECXERR)
+10 IF ECXERR
DO AUDIT^ECXKILL
QUIT
+11 SET ECXPORT=$$EXPORT^ECXUTL1
if ECXPORT=-1
QUIT
IF $GET(ECXPORT)
Begin DoDot:1
+12 KILL ^TMP($JOB,"ECXPORT")
+13 SET ^TMP($JOB,"ECXPORT",0)="EXTRACT LOG #^DIVISION/SITE^IMAGING TYPE (FEEDER LOCATION)^PROCEDURE DATE^FEEDER KEY^PROCEDURE^PATIENT DFN"
SET CNT=1
+14 DO PROCESS
+15 DO EXPDISP^ECXUTL1
+16 DO AUDIT^ECXKILL
End DoDot:1
QUIT
+17 WRITE !!
+18 SET ECXPGM="PROCESS^ECXRACPT"
SET ECXDESC="Radiology Extract Invalid CPT Report"
+19 SET ECXSAVE("ECXHEAD")=""
SET ECXSAVE("ECXDIV(")=""
SET ECXSAVE("ECXARRAY(")=""
+20 WRITE !
+21 DO DEVICE^ECXUTLA(ECXPGM,ECXDESC,.ECXSAVE)
+22 IF ECXSAVE("POP")=1
Begin DoDot:1
+23 WRITE !!,?5,"Try again later... exiting.",!
+24 DO AUDIT^ECXKILL
End DoDot:1
QUIT
+25 IF ECXSAVE("ZTSK")=0
Begin DoDot:1
+26 KILL ECXSAVE,ECXPGM,ECXDESC
+27 DO PROCESS
End DoDot:1
+28 IF IO'=IO(0)
DO ^%ZISC
+29 DO HOME^%ZIS
+30 DO AUDIT^ECXKILL
+31 QUIT
+32 ;
PROCESS ;queued entry
+1 NEW J,X,Y,PG,DIV,EC,ECFK,ECFL,QFLG,TYPE,TYPENMN,DIQ,DR,DA,DIR,DIRUT,DTOUT,DUOUT,CPT,DAY,%DT,ECXRUN,ECX,DIC,ECXEXT,ECXDEF,DATA,SEQ,ECXP
+2 KILL ^TMP($JOB,"ECXCPT")
+3 SET ECXEXT=ECXARRAY("EXTRACT")
SET ECXDEF=ECXARRAY("DEF")
+4 SET (QFLG,PG)=0
+5 ;get run date in external format
+6 SET ECXRUN=$$FMTE^XLFDT($EXTRACT($$NOW^XLFDT,1,12))
+7 ;setup array of imaging types
+8 SET TYPE=0
FOR
SET TYPE=$ORDER(^RA(79.2,TYPE))
if +TYPE<1
QUIT
Begin DoDot:1
+9 KILL ECX
SET DIC="^RA(79.2,"
SET DR=".01;3"
SET DIQ="ECX"
SET DIQ(0)="I"
SET DA=TYPE
DO EN^DIQ1
+10 SET TYPE(TYPE)=ECX(79.2,TYPE,.01,"I")_U_ECX(79.2,TYPE,3,"I")
End DoDot:1
+11 ;process the extract records
+12 SET J=""
FOR
SET J=$ORDER(^ECX(727.814,"AC",ECXEXT,J))
if 'J
QUIT
IF $DATA(^ECX(727.814,J,0))
SET EC=^(0)
SET DIV=$PIECE(EC,U,4)
SET ECFL=DIV_"-"_$PIECE(EC,U,21)
Begin DoDot:1
+13 SET ECFK=$PIECE(EC,U,10)
SET ECXP=$PIECE(EC,U,11)
+14 ;Get just CPT code from the CPT Code and modifier info in ECFK
SET CPT=$EXTRACT(ECFK,1,5)
+15 ;Convert DSS to readable date
SET DAY=$$ECXDATEX^ECXUTL($PIECE(EC,U,9))
+16 ;Convert readable date to FM date
SET X=DAY
SET %DT="X"
DO ^%DT
SET DAY=Y
+17 ;If CPT code was valid on this date, skip it
IF $$STATCHK^ICPTAPIU(CPT,DAY)
QUIT
+18 SET ^TMP($JOB,"ECXCPT",DIV,ECFL,J)=DAY_U_ECXP_U_$$GET1^DIQ(71,$PIECE(EC,U,11),.01)_U_$PIECE(EC,U,5)
+19 QUIT
End DoDot:1
+20 ;
+21 ;Print/export report
+22 USE IO
+23 IF '$GET(ECXPORT)
IF '$DATA(^TMP($JOB,"ECXCPT"))
SET DIV=0
DO HEADER
WRITE !,"No data found."
QUIT
+24 SET DIV=""
FOR
SET DIV=$ORDER(^TMP($JOB,"ECXCPT",DIV))
if DIV=""!(QFLG)
QUIT
Begin DoDot:1
+25 if '$GET(ECXPORT)
DO HEADER
+26 SET ECFL=""
FOR
SET ECFL=$ORDER(^TMP($JOB,"ECXCPT",DIV,ECFL))
if ECFL=""!(QFLG)
QUIT
SET TYPE=+$PIECE(ECFL,"-",2)
Begin DoDot:2
+27 SET TYPENMN=$EXTRACT($PIECE($GET(TYPE(TYPE)),U),1,18)
+28 SET SEQ=""
FOR
SET SEQ=$ORDER(^TMP($JOB,"ECXCPT",DIV,ECFL,SEQ))
if SEQ=""!(QFLG)
QUIT
Begin DoDot:3
+29 IF '$GET(ECXPORT)
if ($Y+3>IOSL)
DO HEADER
if QFLG
QUIT
+30 SET DATA=^TMP($JOB,"ECXCPT",DIV,ECFL,SEQ)
+31 IF $GET(ECXPORT)
Begin DoDot:4
+32 SET ^TMP($JOB,"ECXPORT",CNT)=ECXEXT_U_$PIECE($GET(ECXDIV(DIV)),U,2)_"("_$PIECE($GET(ECXDIV(DIV)),U)_")"_U_TYPENMN_" ("_ECFL_")"
+33 SET ^TMP($JOB,"ECXPORT",CNT)=^TMP($JOB,"ECXPORT",CNT)_U_$TRANSLATE($$FMTE^XLFDT($PIECE(DATA,U),"2F")," ",0)_U_$PIECE(DATA,U,2)_U_$PIECE(DATA,U,3)_U_$PIECE(DATA,U,4)
SET CNT=CNT+1
QUIT
End DoDot:4
QUIT
+34 WRITE TYPENMN," (",ECFL,")"
+35 WRITE !,?3,$PIECE(DATA,U,2),?11,$EXTRACT($PIECE(DATA,U,3),1,45),?58,$TRANSLATE($$FMTE^XLFDT($PIECE(DATA,U),"2F")," ",0),?69,$PIECE(DATA,U,4),!
+36 QUIT
End DoDot:3
+37 QUIT
End DoDot:2
+38 QUIT
End DoDot:1
+39 QUIT
+40 ;
+1 NEW JJ,SS,LN
+2 SET $PIECE(LN,"-",80)="-"
+3 IF $EXTRACT(IOST)="C"
Begin DoDot:1
+4 SET SS=22-$Y
FOR JJ=1:1:SS
WRITE !
+5 IF PG>0
SET DIR(0)="E"
WRITE !
DO ^DIR
KILL DIR
if 'Y
SET QFLG=1
End DoDot:1
+6 if QFLG
QUIT
+7 if $Y!($EXTRACT(IOST)="C")
WRITE @IOF
SET PG=PG+1
+8 WRITE !,"Radiology (RAD) Extract CPT Code Audit"
+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 IF $DATA(ECXDIV(DIV))
WRITE !,"Division/Site: "_$PIECE(ECXDIV(DIV),U,2)_" ("_DIV_")",?68,"Page: "_PG
+13 IF '$DATA(ECXDIV(DIV))
WRITE !,"Division/Site: "_"Unknown",?68,"Page: "_PG
+14 WRITE !!,"Imaging Type (Feeder Location)",?58,"Procedure"
+15 WRITE !?3,"FdrKey",?11,"Procedure",?58,"Date",?69,"DFN"
+16 WRITE !,LN,!
+17 QUIT