ECXSARAD ;BIR/DMA-SAS Report from Radiology Extract; 25 Apr 95 / 11:03 AM ;4/25/14 12:47
;;3.0;DSS EXTRACTS;**8,149**;Dec 22, 1997;Build 27
EN ;entry point from menu option
N ECXPORT,CNT ;149
W @IOF,!!,"Radiology Extract SAS Report",!!
;ecxaud=1 for 'sas' audit
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 ;149 Section added
.K ^TMP($J,"ECXPORT")
.S ^TMP($J,"ECXPORT",0)="EXTRACT LOG #^DIVISION/SITE^FEEDER LOCATION^FEEDER KEY^QUANTITY",CNT=1
.D PROCESS
.D EXPDISP^ECXUTL1
.D AUDIT^ECXKILL
W !!
S ECXPGM="PROCESS^ECXSARAD",ECXDESC="Radiology Extract SAS 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.",! ;149 Fixed spelling of "again"
.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,K,X,Y,JJ,SS,LN,PG,DIV,EC,ECFK,ECFL,QFLG,TOT,TYPE,TYPENM,DIQ,DR,DA,DIR,DIRUT,DTOUT,DUOUT
K ^TMP($J,"ECXAUD")
S ECXEXT=ECXARRAY("EXTRACT"),ECXDEF=ECXARRAY("DEF")
S (QFLG,PG)=0,$P(LN,"-",80)=""
;get run date in external format
D NOW^%DTC S Y=$E(%,1,12) D DD^%DT S ECXRUN=Y
;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) I ECFK="" S ECFK=$P(EC,U,11)
.I $P(EC,U,10)="",$P(EC,U,11)=468 S ECFK=777777
.S MODS=";"_$P(EC,U,17)_";"
.S ^(ECFK)=$G(^TMP($J,"ECXAUD",DIV,ECFL,ECFK))+1
.I MODS[";1;" S ^(ECFK)=$G(^TMP($J,"ECXAUD",DIV,ECFL,ECFK))+1
.I MODS[";2;" S ^(888888)=$G(^TMP($J,"ECXAUD",DIV,ECFL,888888))+1
.I MODS[";3;" S ^(999999)=$G(^TMP($J,"ECXAUD",DIV,ECFL,999999))+1
;print the report
U IO
S DIV="" F S DIV=$O(^TMP($J,"ECXAUD",DIV)) Q:DIV="" D Q:QFLG
.D:'$G(ECXPORT) HEADER S TOT("D")=0 ;149
.S ECFL="" F S ECFL=$O(^TMP($J,"ECXAUD",DIV,ECFL)) Q:ECFL="" S TYPE=+$P(ECFL,"-",2) D Q:QFLG
..S TYPENM=$P($G(TYPE(TYPE)),U,1),TYPENM=$E(TYPENM,1,18),TOT("FL")=0
..S ECFK="" F S ECFK=$O(^TMP($J,"ECXAUD",DIV,ECFL,ECFK)) Q:ECFK="" S TOT=^(ECFK) D Q:QFLG
...I '$G(ECXPORT) D:($Y+3>IOSL) HEADER Q:QFLG W !,?3,ECFL,?43,ECFK,?68,$$RJ^XLFSTR(TOT,5," ") ;149
...I $G(ECXPORT) S ^TMP($J,"ECXPORT",CNT)=ECXEXT_U_$P($G(ECXDIV(DIV)),U,2)_"("_$P($G(ECXDIV(DIV)),U)_")"_U_ECFL_" ("_TYPENM_")"_U_ECFK_U_TOT,CNT=CNT+1 ;149
...S TOT("FL")=TOT("FL")+TOT,TOT("D")=TOT("D")+TOT
..I $G(ECXPORT) S ^TMP($J,"ECXPORT",CNT)="^^Total for Feeder Location "_DIV_"-"_TYPENM_" ("_ECFL_")^^"_TOT("FL"),CNT=CNT+1,^TMP($J,"ECXPORT",CNT)="^",CNT=CNT+1 ;149
..I '$G(ECXPORT) D:($Y+3>IOSL) HEADER Q:QFLG W !,?40,$E(LN,1,34) ;149
..I '$G(ECXPORT) D:($Y+3>IOSL) HEADER Q:QFLG W !,"Total for Feeder Location "_DIV_"-"_TYPENM_" ("_ECFL_"):",?68,$$RJ^XLFSTR(TOT("FL"),5," ") ;149
.I $G(ECXPORT) S ^TMP($J,"ECXPORT",CNT)="^^Grand Total for Division "_DIV_"^^"_TOT("D"),CNT=CNT+1,^TMP($J,"ECXPORT",CNT)="^" ;149
.I '$G(ECXPORT) D:($Y+3>IOSL) HEADER Q:QFLG W !!,"Grand Total for Division "_DIV_":",?68,$$RJ^XLFSTR(TOT("D"),5," ") ;149
;close
I $G(ECXPORT) Q ;149
I $E(IOST)'="C" W @IOF
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
D AUDIT^ECXKILL
Q
D SASHEAD^ECXUTLA(DIV,ECXHEAD,.ECXDIV,.ECXARRAY,.PG)
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HECXSARAD 3910 printed Dec 13, 2024@01:53:45 Page 2
ECXSARAD ;BIR/DMA-SAS Report from Radiology Extract; 25 Apr 95 / 11:03 AM ;4/25/14 12:47
+1 ;;3.0;DSS EXTRACTS;**8,149**;Dec 22, 1997;Build 27
EN ;entry point from menu option
+1 ;149
NEW ECXPORT,CNT
+2 WRITE @IOF,!!,"Radiology Extract SAS Report",!!
+3 ;ecxaud=1 for 'sas' audit
+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 ;149 Section added
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^FEEDER LOCATION^FEEDER KEY^QUANTITY"
SET CNT=1
+14 DO PROCESS
+15 DO EXPDISP^ECXUTL1
+16 DO AUDIT^ECXKILL
End DoDot:1
QUIT
+17 WRITE !!
+18 SET ECXPGM="PROCESS^ECXSARAD"
SET ECXDESC="Radiology Extract SAS 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 ;149 Fixed spelling of "again"
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,K,X,Y,JJ,SS,LN,PG,DIV,EC,ECFK,ECFL,QFLG,TOT,TYPE,TYPENM,DIQ,DR,DA,DIR,DIRUT,DTOUT,DUOUT
+2 KILL ^TMP($JOB,"ECXAUD")
+3 SET ECXEXT=ECXARRAY("EXTRACT")
SET ECXDEF=ECXARRAY("DEF")
+4 SET (QFLG,PG)=0
SET $PIECE(LN,"-",80)=""
+5 ;get run date in external format
+6 DO NOW^%DTC
SET Y=$EXTRACT(%,1,12)
DO DD^%DT
SET ECXRUN=Y
+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)
IF ECFK=""
SET ECFK=$PIECE(EC,U,11)
+14 IF $PIECE(EC,U,10)=""
IF $PIECE(EC,U,11)=468
SET ECFK=777777
+15 SET MODS=";"_$PIECE(EC,U,17)_";"
+16 SET ^(ECFK)=$GET(^TMP($JOB,"ECXAUD",DIV,ECFL,ECFK))+1
+17 IF MODS[";1;"
SET ^(ECFK)=$GET(^TMP($JOB,"ECXAUD",DIV,ECFL,ECFK))+1
+18 IF MODS[";2;"
SET ^(888888)=$GET(^TMP($JOB,"ECXAUD",DIV,ECFL,888888))+1
+19 IF MODS[";3;"
SET ^(999999)=$GET(^TMP($JOB,"ECXAUD",DIV,ECFL,999999))+1
End DoDot:1
+20 ;print the report
+21 USE IO
+22 SET DIV=""
FOR
SET DIV=$ORDER(^TMP($JOB,"ECXAUD",DIV))
if DIV=""
QUIT
Begin DoDot:1
+23 ;149
if '$GET(ECXPORT)
DO HEADER
SET TOT("D")=0
+24 SET ECFL=""
FOR
SET ECFL=$ORDER(^TMP($JOB,"ECXAUD",DIV,ECFL))
if ECFL=""
QUIT
SET TYPE=+$PIECE(ECFL,"-",2)
Begin DoDot:2
+25 SET TYPENM=$PIECE($GET(TYPE(TYPE)),U,1)
SET TYPENM=$EXTRACT(TYPENM,1,18)
SET TOT("FL")=0
+26 SET ECFK=""
FOR
SET ECFK=$ORDER(^TMP($JOB,"ECXAUD",DIV,ECFL,ECFK))
if ECFK=""
QUIT
SET TOT=^(ECFK)
Begin DoDot:3
+27 ;149
IF '$GET(ECXPORT)
if ($Y+3>IOSL)
DO HEADER
if QFLG
QUIT
WRITE !,?3,ECFL,?43,ECFK,?68,$$RJ^XLFSTR(TOT,5," ")
+28 ;149
IF $GET(ECXPORT)
SET ^TMP($JOB,"ECXPORT",CNT)=ECXEXT_U_$PIECE($GET(ECXDIV(DIV)),U,2)_"("_$PIECE($GET(ECXDIV(DIV)),U)_")"_U_ECFL_" ("_TYPENM_")"_U_ECFK_U_TOT
SET CNT=CNT+1
+29 SET TOT("FL")=TOT("FL")+TOT
SET TOT("D")=TOT("D")+TOT
End DoDot:3
if QFLG
QUIT
+30 ;149
IF $GET(ECXPORT)
SET ^TMP($JOB,"ECXPORT",CNT)="^^Total for Feeder Location "_DIV_"-"_TYPENM_" ("_ECFL_")^^"_TOT("FL")
SET CNT=CNT+1
SET ^TMP($JOB,"ECXPORT",CNT)="^"
SET CNT=CNT+1
+31 ;149
IF '$GET(ECXPORT)
if ($Y+3>IOSL)
DO HEADER
if QFLG
QUIT
WRITE !,?40,$EXTRACT(LN,1,34)
+32 ;149
IF '$GET(ECXPORT)
if ($Y+3>IOSL)
DO HEADER
if QFLG
QUIT
WRITE !,"Total for Feeder Location "_DIV_"-"_TYPENM_" ("_ECFL_"):",?68,$$RJ^XLFSTR(TOT("FL"),5," ")
End DoDot:2
if QFLG
QUIT
+33 ;149
IF $GET(ECXPORT)
SET ^TMP($JOB,"ECXPORT",CNT)="^^Grand Total for Division "_DIV_"^^"_TOT("D")
SET CNT=CNT+1
SET ^TMP($JOB,"ECXPORT",CNT)="^"
+34 ;149
IF '$GET(ECXPORT)
if ($Y+3>IOSL)
DO HEADER
if QFLG
QUIT
WRITE !!,"Grand Total for Division "_DIV_":",?68,$$RJ^XLFSTR(TOT("D"),5," ")
End DoDot:1
if QFLG
QUIT
+35 ;close
+36 ;149
IF $GET(ECXPORT)
QUIT
+37 IF $EXTRACT(IOST)'="C"
WRITE @IOF
+38 IF $EXTRACT(IOST)="C"
IF 'QFLG
Begin DoDot:1
+39 SET SS=22-$Y
FOR JJ=1:1:SS
WRITE !
+40 SET DIR(0)="E"
WRITE !
DO ^DIR
KILL DIR
End DoDot:1
+41 DO AUDIT^ECXKILL
+42 QUIT
+1 DO SASHEAD^ECXUTLA(DIV,ECXHEAD,.ECXDIV,.ECXARRAY,.PG)
+2 QUIT