PRCPRQDR ;WISC/RFJ-quantity distribution report (option, whse) ;10 Jun 93
V ;;5.1;IFCAP;**1**;Oct 20, 2000
;Per VHA Directive 10-93-142, this routine should not be modified.
D ^PRCPUSEL Q:'$G(PRCP("I"))
I PRCP("DPTYPE")="P" D PRIMARY^PRCPRQDP Q
I PRCP("DPTYPE")="S" D SECONDY^PRCPRQDP Q
;
; quantity distribution report for whse
N PRCPEND,PRCPSTRT,X
K X S X(1)="The Quantity Distribution Report will display all sales from the Warehouse to the Primary inventory points. This report is sorted by NSN and date issued."
D DISPLAY^PRCPUX2(40,79,.X)
;
K X S X(1)="Select the range of NSNs to display"
W !! D DISPLAY^PRCPUX2(2,40,.X)
D NSNSEL^PRCPURS0
I '$D(PRCPSTRT) Q
;
W ! S %ZIS="Q" D ^%ZIS
G:POP Q
I $D(IO("Q")) D D ^%ZTLOAD K IO("Q"),ZTSK D Q Q
. S ZTDESC="Quantity Distribution Report",ZTRTN="DQ^PRCPRQDR"
. S ZTSAVE("PRCP*")="",ZTSAVE("ZTREQ")="@"
W !!,"<*> please wait <*>"
;
DQ ; queue starts here
N %,%H,%I,COUNT,CURRENT,DA,DATA,DATE,DATEDAT,DATEEDT,DATESDT,DATESTRT,H,ITEMDA,ITEMDATA,L,NOW,NSN,PAGE,PRCPDATA,PRCPFLAG,Q,QTY,SCREEN,TOTALC,TOTALQ,TOTALV,TYPE,V,VALUE,X,Y
K DATEDAT
S CURRENT=$E(DT,1,5)_"00"
S X1=$E(DT,1,5)_"15"
S X2=-375
D C^%DTC S (DATESTRT,Y)=$E(X,1,5)_"00"
D DD^%DT S DATEDAT($E(X,1,5))=$P(Y," ")_$E(X,2,3)
S DATE=$E(DATESTRT,1,5)_"15"
F S X1=DATE,X2=30 D Q:$E(X,1,5)'<$E(CURRENT,1,5) S DATE=$E(X,1,5)_"15"
. D C^%DTC S Y=$E(X,1,5)_"00"
. D DD^%DT
. S DATEDAT($E(X,1,5))=$P(Y," ")_$E(X,2,3)
K ^TMP($J,"PRCPRQDR")
;
S DATE=DATESTRT-.01
F S DATE=$O(^PRCP(445.2,"AX",PRCP("I"),DATE)) Q:'DATE!($E(DATE,1,5)>$E(CURRENT,1,5)) F TYPE="R","C","E" S DA=0 F S DA=$O(^PRCP(445.2,"AX",PRCP("I"),DATE,TYPE,DA)) Q:'DA D
. S DATA=$G(^PRCP(445.2,DA,0)) I DATA="" Q
. S ITEMDA=$P(DATA,"^",5),NSN=$$NSN^PRCPUX1(ITEMDA) S:NSN="" NSN=" "
. I $E(NSN,1,$L(PRCPSTRT))'=PRCPSTRT,$E(NSN,1,$L(PRCPEND))'=PRCPEND I NSN']PRCPSTRT!(PRCPEND']NSN) Q
. S $P(DATA,"^",7)=-$P(DATA,"^",7)
. I '$P(DATA,"^",23) S $P(DATA,"^",23)=$J($P(DATA,"^",7)*$P(DATA,"^",9),0,2)
. I $P(DATA,"^",23)<0 S $P(DATA,"^",23)=-$P(DATA,"^",23)
. S %=$G(^TMP($J,"PRCPRQDR",NSN,ITEMDA,$E(DATE,1,5)))
. S ^TMP($J,"PRCPRQDR",NSN,ITEMDA,$E(DATE,1,5))=($P(DATA,"^",7)+$P(%,"^"))_"^"_($P(DATA,"^",23)+$P(%,"^",2))
; print report
S Y=DATESTRT D DD^%DT S DATESDT=Y,Y=DT D DD^%DT S DATEEDT=Y
D NOW^%DTC S Y=% D DD^%DT S NOW=Y
S PAGE=1,SCREEN=$$SCRPAUSE^PRCPUREP U IO D H
S NSN=""
F S NSN=$O(^TMP($J,"PRCPRQDR",NSN)) Q:NSN=""!($G(PRCPFLAG)) S ITEMDA=0 F S ITEMDA=$O(^TMP($J,"PRCPRQDR",NSN,ITEMDA)) Q:'ITEMDA!($G(PRCPFLAG)) D
. I $G(ZTQUEUED),$$S^%ZTLOAD S PRCPFLAG=1 W !?10,"<<< TASKMANAGER JOB TERMINATED BY USER >>>" Q
. I $Y>(IOSL-8) D:SCREEN P^PRCPUREP Q:$D(PRCPFLAG) D H
. S ITEMDATA=$G(^PRCP(445,PRCP("I"),1,ITEMDA,0))
. W !!,$TR(NSN,"-")
. W ?15,$E($$DESCR^PRCPUX1(PRCP("I"),ITEMDA),1,18)
. W ?34,ITEMDA
. W ?39,$J($$UNIT^PRCPUX1(PRCP("I"),ITEMDA,"/"),7)
. W $J($P(ITEMDATA,"^",10),6)
. W $J($P(ITEMDATA,"^",4),7)
. W $J($P(ITEMDATA,"^",23),7)
. W $J($P(ITEMDATA,"^",11),7)
. W $J($P(ITEMDATA,"^",9),7)
. S (H(0),H(1),Q(0),Q(1),V(0),V(1))=""
. S (COUNT,DATE,L,TOTALC,TOTALQ,TOTALV)=0
. F S DATE=$O(DATEDAT(DATE)) Q:'DATE S PRCPDATA=$G(^TMP($J,"PRCPRQDR",NSN,ITEMDA,DATE)) D
. . S QTY=+$P(PRCPDATA,"^") I QTY=0 S QTY="..."
. . S VALUE=$J($P(PRCPDATA,"^",2),0,2) I VALUE="0.00" S VALUE="..."
. . I TOTALC'=12 S TOTALQ=TOTALQ+$P(PRCPDATA,"^"),TOTALV=TOTALV+$P(PRCPDATA,"^",2),TOTALC=TOTALC+1
. . S H(L)=H(L)_$J(DATEDAT(DATE),10),Q(L)=Q(L)_$J(QTY,10),V(L)=V(L)_$J(VALUE,10),COUNT=COUNT+1
. . I COUNT=6 S L=1,COUNT=0
. S H(1)=H(1)_$J("AVG",10),Q(1)=Q(1)_$J(TOTALQ/TOTALC,10,0),V(1)=V(1)_$J(TOTALV/TOTALC,10,2)
. W !,H(0),?79,"^",!,Q(0),?79,"|",!,V(0),?79,"v",!,H(1),!,Q(1),!,V(1)
I $G(PRCPFLAG) D Q Q
D END^PRCPUREP
Q D ^%ZISC K ^TMP($J,"PRCPRQDR")
Q
;
H S %=NOW_" PAGE "_PAGE,PAGE=PAGE+1 I PAGE'=2!(SCREEN) W @IOF
W $C(13),"QUANTITY DISTRIBUTION REPORT FOR: ",$E(PRCP("IN"),1,20),?(80-$L(%)),%
W !?5,"QUANTITY DISTRIBUTION DATE RANGE: ",DATESDT," TO ",DATEEDT
S %="",$P(%,"-",81)=""
W !?46,$J("STAND",6),$J("OPT",7),$J("TEMP",7),$J("EMER",7),$J("NORM",7),!,"NSN",?15,"DESCRIPTION",?34,"MI#",?39,$J("UNIT/IS",7),$J("REOPT",6),$J("REOPT",7),$J("S.LVL",7),$J("S.LVL",7),$J("S.LVL",7)
W !,%
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPRCPRQDR 4428 printed Nov 22, 2024@17:25:33 Page 2
PRCPRQDR ;WISC/RFJ-quantity distribution report (option, whse) ;10 Jun 93
V ;;5.1;IFCAP;**1**;Oct 20, 2000
+1 ;Per VHA Directive 10-93-142, this routine should not be modified.
+2 DO ^PRCPUSEL
if '$GET(PRCP("I"))
QUIT
+3 IF PRCP("DPTYPE")="P"
DO PRIMARY^PRCPRQDP
QUIT
+4 IF PRCP("DPTYPE")="S"
DO SECONDY^PRCPRQDP
QUIT
+5 ;
+6 ; quantity distribution report for whse
+7 NEW PRCPEND,PRCPSTRT,X
+8 KILL X
SET X(1)="The Quantity Distribution Report will display all sales from the Warehouse to the Primary inventory points. This report is sorted by NSN and date issued."
+9 DO DISPLAY^PRCPUX2(40,79,.X)
+10 ;
+11 KILL X
SET X(1)="Select the range of NSNs to display"
+12 WRITE !!
DO DISPLAY^PRCPUX2(2,40,.X)
+13 DO NSNSEL^PRCPURS0
+14 IF '$DATA(PRCPSTRT)
QUIT
+15 ;
+16 WRITE !
SET %ZIS="Q"
DO ^%ZIS
+17 if POP
GOTO Q
+18 IF $DATA(IO("Q"))
Begin DoDot:1
+19 SET ZTDESC="Quantity Distribution Report"
SET ZTRTN="DQ^PRCPRQDR"
+20 SET ZTSAVE("PRCP*")=""
SET ZTSAVE("ZTREQ")="@"
End DoDot:1
DO ^%ZTLOAD
KILL IO("Q"),ZTSK
DO Q
QUIT
+21 WRITE !!,"<*> please wait <*>"
+22 ;
DQ ; queue starts here
+1 NEW %,%H,%I,COUNT,CURRENT,DA,DATA,DATE,DATEDAT,DATEEDT,DATESDT,DATESTRT,H,ITEMDA,ITEMDATA,L,NOW,NSN,PAGE,PRCPDATA,PRCPFLAG,Q,QTY,SCREEN,TOTALC,TOTALQ,TOTALV,TYPE,V,VALUE,X,Y
+2 KILL DATEDAT
+3 SET CURRENT=$EXTRACT(DT,1,5)_"00"
+4 SET X1=$EXTRACT(DT,1,5)_"15"
+5 SET X2=-375
+6 DO C^%DTC
SET (DATESTRT,Y)=$EXTRACT(X,1,5)_"00"
+7 DO DD^%DT
SET DATEDAT($EXTRACT(X,1,5))=$PIECE(Y," ")_$EXTRACT(X,2,3)
+8 SET DATE=$EXTRACT(DATESTRT,1,5)_"15"
+9 FOR
SET X1=DATE
SET X2=30
Begin DoDot:1
+10 DO C^%DTC
SET Y=$EXTRACT(X,1,5)_"00"
+11 DO DD^%DT
+12 SET DATEDAT($EXTRACT(X,1,5))=$PIECE(Y," ")_$EXTRACT(X,2,3)
End DoDot:1
if $EXTRACT(X,1,5)'<$EXTRACT(CURRENT,1,5)
QUIT
SET DATE=$EXTRACT(X,1,5)_"15"
+13 KILL ^TMP($JOB,"PRCPRQDR")
+14 ;
+15 SET DATE=DATESTRT-.01
+16 FOR
SET DATE=$ORDER(^PRCP(445.2,"AX",PRCP("I"),DATE))
if 'DATE!($EXTRACT(DATE,1,5)>$EXTRACT(CURRENT,1,5))
QUIT
FOR TYPE="R","C","E"
SET DA=0
FOR
SET DA=$ORDER(^PRCP(445.2,"AX",PRCP("I"),DATE,TYPE,DA))
if 'DA
QUIT
Begin DoDot:1
+17 SET DATA=$GET(^PRCP(445.2,DA,0))
IF DATA=""
QUIT
+18 SET ITEMDA=$PIECE(DATA,"^",5)
SET NSN=$$NSN^PRCPUX1(ITEMDA)
if NSN=""
SET NSN=" "
+19 IF $EXTRACT(NSN,1,$LENGTH(PRCPSTRT))'=PRCPSTRT
IF $EXTRACT(NSN,1,$LENGTH(PRCPEND))'=PRCPEND
IF NSN']PRCPSTRT!(PRCPEND']NSN)
QUIT
+20 SET $PIECE(DATA,"^",7)=-$PIECE(DATA,"^",7)
+21 IF '$PIECE(DATA,"^",23)
SET $PIECE(DATA,"^",23)=$JUSTIFY($PIECE(DATA,"^",7)*$PIECE(DATA,"^",9),0,2)
+22 IF $PIECE(DATA,"^",23)<0
SET $PIECE(DATA,"^",23)=-$PIECE(DATA,"^",23)
+23 SET %=$GET(^TMP($JOB,"PRCPRQDR",NSN,ITEMDA,$EXTRACT(DATE,1,5)))
+24 SET ^TMP($JOB,"PRCPRQDR",NSN,ITEMDA,$EXTRACT(DATE,1,5))=($PIECE(DATA,"^",7)+$PIECE(%,"^"))_"^"_($PIECE(DATA,"^",23)+$PIECE(%,"^",2))
End DoDot:1
+25 ; print report
+26 SET Y=DATESTRT
DO DD^%DT
SET DATESDT=Y
SET Y=DT
DO DD^%DT
SET DATEEDT=Y
+27 DO NOW^%DTC
SET Y=%
DO DD^%DT
SET NOW=Y
+28 SET PAGE=1
SET SCREEN=$$SCRPAUSE^PRCPUREP
USE IO
DO H
+29 SET NSN=""
+30 FOR
SET NSN=$ORDER(^TMP($JOB,"PRCPRQDR",NSN))
if NSN=""!($GET(PRCPFLAG))
QUIT
SET ITEMDA=0
FOR
SET ITEMDA=$ORDER(^TMP($JOB,"PRCPRQDR",NSN,ITEMDA))
if 'ITEMDA!($GET(PRCPFLAG))
QUIT
Begin DoDot:1
+31 IF $GET(ZTQUEUED)
IF $$S^%ZTLOAD
SET PRCPFLAG=1
WRITE !?10,"<<< TASKMANAGER JOB TERMINATED BY USER >>>"
QUIT
+32 IF $Y>(IOSL-8)
if SCREEN
DO P^PRCPUREP
if $DATA(PRCPFLAG)
QUIT
DO H
+33 SET ITEMDATA=$GET(^PRCP(445,PRCP("I"),1,ITEMDA,0))
+34 WRITE !!,$TRANSLATE(NSN,"-")
+35 WRITE ?15,$EXTRACT($$DESCR^PRCPUX1(PRCP("I"),ITEMDA),1,18)
+36 WRITE ?34,ITEMDA
+37 WRITE ?39,$JUSTIFY($$UNIT^PRCPUX1(PRCP("I"),ITEMDA,"/"),7)
+38 WRITE $JUSTIFY($PIECE(ITEMDATA,"^",10),6)
+39 WRITE $JUSTIFY($PIECE(ITEMDATA,"^",4),7)
+40 WRITE $JUSTIFY($PIECE(ITEMDATA,"^",23),7)
+41 WRITE $JUSTIFY($PIECE(ITEMDATA,"^",11),7)
+42 WRITE $JUSTIFY($PIECE(ITEMDATA,"^",9),7)
+43 SET (H(0),H(1),Q(0),Q(1),V(0),V(1))=""
+44 SET (COUNT,DATE,L,TOTALC,TOTALQ,TOTALV)=0
+45 FOR
SET DATE=$ORDER(DATEDAT(DATE))
if 'DATE
QUIT
SET PRCPDATA=$GET(^TMP($JOB,"PRCPRQDR",NSN,ITEMDA,DATE))
Begin DoDot:2
+46 SET QTY=+$PIECE(PRCPDATA,"^")
IF QTY=0
SET QTY="..."
+47 SET VALUE=$JUSTIFY($PIECE(PRCPDATA,"^",2),0,2)
IF VALUE="0.00"
SET VALUE="..."
+48 IF TOTALC'=12
SET TOTALQ=TOTALQ+$PIECE(PRCPDATA,"^")
SET TOTALV=TOTALV+$PIECE(PRCPDATA,"^",2)
SET TOTALC=TOTALC+1
+49 SET H(L)=H(L)_$JUSTIFY(DATEDAT(DATE),10)
SET Q(L)=Q(L)_$JUSTIFY(QTY,10)
SET V(L)=V(L)_$JUSTIFY(VALUE,10)
SET COUNT=COUNT+1
+50 IF COUNT=6
SET L=1
SET COUNT=0
End DoDot:2
+51 SET H(1)=H(1)_$JUSTIFY("AVG",10)
SET Q(1)=Q(1)_$JUSTIFY(TOTALQ/TOTALC,10,0)
SET V(1)=V(1)_$JUSTIFY(TOTALV/TOTALC,10,2)
+52 WRITE !,H(0),?79,"^",!,Q(0),?79,"|",!,V(0),?79,"v",!,H(1),!,Q(1),!,V(1)
End DoDot:1
+53 IF $GET(PRCPFLAG)
DO Q
QUIT
+54 DO END^PRCPUREP
Q DO ^%ZISC
KILL ^TMP($JOB,"PRCPRQDR")
+1 QUIT
+2 ;
H SET %=NOW_" PAGE "_PAGE
SET PAGE=PAGE+1
IF PAGE'=2!(SCREEN)
WRITE @IOF
+1 WRITE $CHAR(13),"QUANTITY DISTRIBUTION REPORT FOR: ",$EXTRACT(PRCP("IN"),1,20),?(80-$LENGTH(%)),%
+2 WRITE !?5,"QUANTITY DISTRIBUTION DATE RANGE: ",DATESDT," TO ",DATEEDT
+3 SET %=""
SET $PIECE(%,"-",81)=""
+4 WRITE !?46,$JUSTIFY("STAND",6),$JUSTIFY("OPT",7),$JUSTIFY("TEMP",7),$JUSTIFY("EMER",7),$JUSTIFY("NORM",7),!,"NSN",?15,"DESCRIPTION",?34,"MI#",?39,$JUSTIFY("UNIT/IS",7),$JUSTIFY("REOPT",6),$JUSTIFY("REOPT",7),$JUSTIFY("S.LVL",7),...
... $JUSTIFY("S.LVL",7),$JUSTIFY("S.LVL",7)
+5 WRITE !,%
+6 QUIT