ECXSARXS ;BIR/DMA-SAS Report from Prescription Extract; 22 Sep 95 / 10:27 AM ;3/27/14 16:11
;;3.0;DSS EXTRACTS;**8,149**;Dec 22, 1997;Build 27
;
EN ;entry point from menu option
N ECXPORT,CNT ;149
W @IOF,!!,"Prescription Extract SAS Report",!!
;ecxaud=1 for 'sas' audit
S ECXHEAD="PRE",ECXAUD=1
;select extract
D AUDIT^ECXUTLA(ECXHEAD,.ECXERR,.ECXARRAY,ECXAUD)
I ECXERR D AUDIT^ECXKILL Q
;select all pharmacy sites/divisions
S ECXALL=1 D PRE^ECXDVSN1(.ECXDIV,ECXALL,.ECXERR)
I ECXERR D AUDIT^ECXKILL Q
S ECXPORT=$$EXPORT^ECXUTL1 Q:ECXPORT=-1 I $G(ECXPORT) D Q ;149 Secition 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^ECXSARXS",ECXDESC="Prescription 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,X,Y,JJ,SS,LN,PG,DIV,EC,ECFK,ECFL,ECQ,MAIL,NEWRX,COPAY,DEA,TOT,QFLG,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
;process the extract records
S J="" F S J=$O(^ECX(727.81,"AC",ECXEXT,J)) Q:'J I $D(^ECX(727.81,J,0)) S EC=^(0) D
.S DIV=$P(EC,U,10),MAIL=+$P(EC,U,13),NEWRX=+$P(EC,U,15),COPAY=+$P(EC,U,27),DEA=$P(EC,U,29)
.;non-cmop rxs only
.;feeder location is always "pre"_div
.I MAIL'=2 D
..S ECFL="PRE"_DIV,ECFK=$P(EC,U,28),ECQ=+$P(EC,U,17)
..S ^(ECFK)=$G(^TMP($J,"ECXAUD",DIV,ECFL,ECFK))+ECQ
..;additional feeder key records for non-cmop rx
..S ECFK="BASIC",ECQ=1,^(ECFK)=$G(^TMP($J,"ECXAUD",DIV,ECFL,ECFK))+ECQ
..I MAIL=1 D
...S ECFK="VAMAIL",ECQ=1,^(ECFK)=$G(^TMP($J,"ECXAUD",DIV,ECFL,ECFK))+ECQ
...I NEWRX=1 D
....S ECFK="NEWVMOP",ECQ=1,^(ECFK)=$G(^TMP($J,"ECXAUD",DIV,ECFL,ECFK))+ECQ
..I MAIL=0&(NEWRX=1) D
...S ECFK="NEWWIN",ECQ=1,^(ECFK)=$G(^TMP($J,"ECXAUD",DIV,ECFL,ECFK))+ECQ
..I COPAY=1 D
...S ECFK="COPAY",ECQ=1,^(ECFK)=$G(^TMP($J,"ECXAUD",DIV,ECFL,ECFK))+ECQ
..I DEA="I" D
...S ECFK="PREDEASP",ECQ=1,^(ECFK)=$G(^TMP($J,"ECXAUD",DIV,ECFL,ECFK))+ECQ
.;cmop rxs only
.;feeder location is "cmopdsu"_div, "cmopdis"_div, and also "pre"_div
.I MAIL=2 D
..S ECFL="CMOPDSU"_DIV,ECFK=$P(EC,U,28),ECQ=+$P(EC,U,17),^(ECFK)=$G(^TMP($J,"ECXAUD",DIV,ECFL,ECFK))+ECQ
..S ECFL="CMOPDIS"_DIV,ECFK="CMOPDISP",ECQ=1,^(ECFK)=$G(^TMP($J,"ECXAUD",DIV,ECFL,ECFK))+ECQ
..S ECFL="PRE"_DIV D
...;possibly three additional feeder key recods for cmop rx
...I NEWRX=1 D
....S ECFK="NEWCMOP",ECQ=1,^(ECFK)=$G(^TMP($J,"ECXAUD",DIV,ECFL,ECFK))+ECQ
...I COPAY=1 D
....S ECFK="COPAY",ECQ=1,^(ECFK)=$G(^TMP($J,"ECXAUD",DIV,ECFL,ECFK))+ECQ
...I DEA="I" D
....S ECFK="PREDEASP",ECQ=1,^(ECFK)=$G(^TMP($J,"ECXAUD",DIV,ECFL,ECFK))+ECQ
;print the report
U IO
S DIV="" F S DIV=$O(^TMP($J,"ECXAUD",DIV)) Q:DIV="" D Q:QFLG
.I '$G(ECXPORT) D HEADER ;149
.S ECFL="" F S ECFL=$O(^TMP($J,"ECXAUD",DIV,ECFL)) Q:ECFL="" D Q:QFLG
..I '$G(ECXPORT) D:($Y+3>IOSL) HEADER Q:QFLG W !,?3,ECFL ;149
..S ECFK="" F S ECFK=$O(^TMP($J,"ECXAUD",DIV,ECFL,ECFK)) Q:ECFK="" S TOT=^(ECFK) D Q:QFLG
...I $G(ECXPORT) S ^TMP($J,"ECXPORT",CNT)=ECXEXT_U_$P($G(ECXDIV(DIV)),U,2)_"("_$P($G(ECXDIV(DIV)),U)_")"_U_ECFL_U_ECFK_U_TOT,CNT=CNT+1 Q ;149
...D:($Y+3>IOSL) HEADER Q:QFLG W ?40,ECFK,?68,$$RJ^XLFSTR(TOT,5," "),!
;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[HECXSARXS 4052 printed Oct 16, 2024@17:54:32 Page 2
ECXSARXS ;BIR/DMA-SAS Report from Prescription Extract; 22 Sep 95 / 10:27 AM ;3/27/14 16:11
+1 ;;3.0;DSS EXTRACTS;**8,149**;Dec 22, 1997;Build 27
+2 ;
EN ;entry point from menu option
+1 ;149
NEW ECXPORT,CNT
+2 WRITE @IOF,!!,"Prescription Extract SAS Report",!!
+3 ;ecxaud=1 for 'sas' audit
+4 SET ECXHEAD="PRE"
SET ECXAUD=1
+5 ;select extract
+6 DO AUDIT^ECXUTLA(ECXHEAD,.ECXERR,.ECXARRAY,ECXAUD)
+7 IF ECXERR
DO AUDIT^ECXKILL
QUIT
+8 ;select all pharmacy sites/divisions
+9 SET ECXALL=1
DO PRE^ECXDVSN1(.ECXDIV,ECXALL,.ECXERR)
+10 IF ECXERR
DO AUDIT^ECXKILL
QUIT
+11 ;149 Secition 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^ECXSARXS"
SET ECXDESC="Prescription 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,X,Y,JJ,SS,LN,PG,DIV,EC,ECFK,ECFL,ECQ,MAIL,NEWRX,COPAY,DEA,TOT,QFLG,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 ;process the extract records
+8 SET J=""
FOR
SET J=$ORDER(^ECX(727.81,"AC",ECXEXT,J))
if 'J
QUIT
IF $DATA(^ECX(727.81,J,0))
SET EC=^(0)
Begin DoDot:1
+9 SET DIV=$PIECE(EC,U,10)
SET MAIL=+$PIECE(EC,U,13)
SET NEWRX=+$PIECE(EC,U,15)
SET COPAY=+$PIECE(EC,U,27)
SET DEA=$PIECE(EC,U,29)
+10 ;non-cmop rxs only
+11 ;feeder location is always "pre"_div
+12 IF MAIL'=2
Begin DoDot:2
+13 SET ECFL="PRE"_DIV
SET ECFK=$PIECE(EC,U,28)
SET ECQ=+$PIECE(EC,U,17)
+14 SET ^(ECFK)=$GET(^TMP($JOB,"ECXAUD",DIV,ECFL,ECFK))+ECQ
+15 ;additional feeder key records for non-cmop rx
+16 SET ECFK="BASIC"
SET ECQ=1
SET ^(ECFK)=$GET(^TMP($JOB,"ECXAUD",DIV,ECFL,ECFK))+ECQ
+17 IF MAIL=1
Begin DoDot:3
+18 SET ECFK="VAMAIL"
SET ECQ=1
SET ^(ECFK)=$GET(^TMP($JOB,"ECXAUD",DIV,ECFL,ECFK))+ECQ
+19 IF NEWRX=1
Begin DoDot:4
+20 SET ECFK="NEWVMOP"
SET ECQ=1
SET ^(ECFK)=$GET(^TMP($JOB,"ECXAUD",DIV,ECFL,ECFK))+ECQ
End DoDot:4
End DoDot:3
+21 IF MAIL=0&(NEWRX=1)
Begin DoDot:3
+22 SET ECFK="NEWWIN"
SET ECQ=1
SET ^(ECFK)=$GET(^TMP($JOB,"ECXAUD",DIV,ECFL,ECFK))+ECQ
End DoDot:3
+23 IF COPAY=1
Begin DoDot:3
+24 SET ECFK="COPAY"
SET ECQ=1
SET ^(ECFK)=$GET(^TMP($JOB,"ECXAUD",DIV,ECFL,ECFK))+ECQ
End DoDot:3
+25 IF DEA="I"
Begin DoDot:3
+26 SET ECFK="PREDEASP"
SET ECQ=1
SET ^(ECFK)=$GET(^TMP($JOB,"ECXAUD",DIV,ECFL,ECFK))+ECQ
End DoDot:3
End DoDot:2
+27 ;cmop rxs only
+28 ;feeder location is "cmopdsu"_div, "cmopdis"_div, and also "pre"_div
+29 IF MAIL=2
Begin DoDot:2
+30 SET ECFL="CMOPDSU"_DIV
SET ECFK=$PIECE(EC,U,28)
SET ECQ=+$PIECE(EC,U,17)
SET ^(ECFK)=$GET(^TMP($JOB,"ECXAUD",DIV,ECFL,ECFK))+ECQ
+31 SET ECFL="CMOPDIS"_DIV
SET ECFK="CMOPDISP"
SET ECQ=1
SET ^(ECFK)=$GET(^TMP($JOB,"ECXAUD",DIV,ECFL,ECFK))+ECQ
+32 SET ECFL="PRE"_DIV
Begin DoDot:3
+33 ;possibly three additional feeder key recods for cmop rx
+34 IF NEWRX=1
Begin DoDot:4
+35 SET ECFK="NEWCMOP"
SET ECQ=1
SET ^(ECFK)=$GET(^TMP($JOB,"ECXAUD",DIV,ECFL,ECFK))+ECQ
End DoDot:4
+36 IF COPAY=1
Begin DoDot:4
+37 SET ECFK="COPAY"
SET ECQ=1
SET ^(ECFK)=$GET(^TMP($JOB,"ECXAUD",DIV,ECFL,ECFK))+ECQ
End DoDot:4
+38 IF DEA="I"
Begin DoDot:4
+39 SET ECFK="PREDEASP"
SET ECQ=1
SET ^(ECFK)=$GET(^TMP($JOB,"ECXAUD",DIV,ECFL,ECFK))+ECQ
End DoDot:4
End DoDot:3
End DoDot:2
End DoDot:1
+40 ;print the report
+41 USE IO
+42 SET DIV=""
FOR
SET DIV=$ORDER(^TMP($JOB,"ECXAUD",DIV))
if DIV=""
QUIT
Begin DoDot:1
+43 ;149
IF '$GET(ECXPORT)
DO HEADER
+44 SET ECFL=""
FOR
SET ECFL=$ORDER(^TMP($JOB,"ECXAUD",DIV,ECFL))
if ECFL=""
QUIT
Begin DoDot:2
+45 ;149
IF '$GET(ECXPORT)
if ($Y+3>IOSL)
DO HEADER
if QFLG
QUIT
WRITE !,?3,ECFL
+46 SET ECFK=""
FOR
SET ECFK=$ORDER(^TMP($JOB,"ECXAUD",DIV,ECFL,ECFK))
if ECFK=""
QUIT
SET TOT=^(ECFK)
Begin DoDot:3
+47 ;149
IF $GET(ECXPORT)
SET ^TMP($JOB,"ECXPORT",CNT)=ECXEXT_U_$PIECE($GET(ECXDIV(DIV)),U,2)_"("_$PIECE($GET(ECXDIV(DIV)),U)_")"_U_ECFL_U_ECFK_U_TOT
SET CNT=CNT+1
QUIT
+48 if ($Y+3>IOSL)
DO HEADER
if QFLG
QUIT
WRITE ?40,ECFK,?68,$$RJ^XLFSTR(TOT,5," "),!
End DoDot:3
if QFLG
QUIT
End DoDot:2
if QFLG
QUIT
End DoDot:1
if QFLG
QUIT
+49 ;close
+50 ;149
IF $GET(ECXPORT)
QUIT
+51 IF $EXTRACT(IOST)'="C"
WRITE @IOF
+52 IF $EXTRACT(IOST)="C"
IF 'QFLG
Begin DoDot:1
+53 SET SS=22-$Y
FOR JJ=1:1:SS
WRITE !
+54 SET DIR(0)="E"
WRITE !
DO ^DIR
KILL DIR
End DoDot:1
+55 DO AUDIT^ECXKILL
+56 QUIT
+57 ;
+1 DO SASHEAD^ECXUTLA(DIV,ECXHEAD,.ECXDIV,.ECXARRAY,.PG)
+2 QUIT