PRCPRISS ;WISC/RFJ-inventory sales (secondary) ;24 May 93
V ;;5.1;IFCAP;**1,41**;Oct 20, 2000
;Per VHA Directive 10-93-142, this routine should not be modified.
Q
;
;
; inventory sales report
SECOND N ANS,DATEEND,DATESTRT,DISTRALL,PRCPEND,PRCPSTRT,PRCPSUMM,X
K X S X(1)="The Inventory Sales Report will display all sales from the Secondary inventory point. This report is sorted by description, the recipient and the date issued." D DISPLAY^PRCPUX2(40,79,.X)
;
K X S X(1)="Select the RECIPIENTS to display" D DISPLAY^PRCPUX2(2,40,.X)
D DISTRSEL^PRCPURS3(PRCP("I"))
I '$G(DISTRALL),$O(^TMP($J,"PRCPURS3","YES",0))']"" W !,"*** NO RECIPIENTS SELECTED !" D Q Q
;
K X S X(1)="Select the range of ISSUE DATES to display" W !! D DISPLAY^PRCPUX2(2,40,.X)
D DATESEL^PRCPURS2("Issue") I '$G(DATEEND) D Q Q
;
S PRCPSUMM=$$SUMMARY^PRCPURS0 I PRCPSUMM<0 D Q 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="Secondary Inventory Sales Report",ZTRTN="DQ^PRCPRISS"
. S ZTSAVE("PRCP*")="",ZTSAVE("DATE*")="",ZTSAVE("DISTRALL")="",ZTSAVE("^TMP($J,""PRCPURS3"",")="",ZTSAVE("ZTREQ")="@"
W !!,"<*> please wait <*>"
;
; queue starts here
DQ N %,%H,%I,DA,DATA,DATE,DATEEDT,DATESDT,DESCR,DISTRNM,DISTRPT,ITEMDA,ITEMDATA,NOW,PAGE,PRCPDATA,PRCPFLAG,SCREEN,TOTALQ,TOTALQI,TOTALV,TOTALVI,X,Y
K ^TMP($J,"PRCPRISP"),^TMP($J,"PRCPRISP TOT")
S DATE=DATESTRT-.01 F S DATE=$O(^PRCP(445.2,"AX",PRCP("I"),DATE)) Q:'DATE!(DATE>DATEEND) S DA=0 F S DA=$O(^PRCP(445.2,"AX",PRCP("I"),DATE,"U",DA)) Q:'DA D
. S DATA=$G(^PRCP(445.2,DA,0)) I DATA="" Q
. S ITEMDA=$P(DATA,"^",5),DESCR=$$DESCR^PRCPUX1(PRCP("I"),ITEMDA) S:DESCR="" DESCR=" "
. S DISTRPT=$P($G(^PRCP(445.2,DA,2)),"^",2)
. I DISTRPT']"",'$G(DISTRALL) Q
. I $G(DISTRALL),$D(^TMP($J,"PRCPURS3","NO",DISTRPT)) Q
. I '$G(DISTRALL),'$D(^TMP($J,"PRCPURS3","YES",DISTRPT)) Q
. S $P(DATA,"^",7)=-$P(DATA,"^",7),$P(DATA,"^",23)=-$P(DATA,"^",23)
. I '$P(DATA,"^",23) S $P(DATA,"^",23)=$J($P(DATA,"^",7)*$P(DATA,"^",8),0,2)
. S ^TMP($J,"PRCPRISP",$E(DESCR,1,10),ITEMDA,$E(DISTRPT,1,24),DATE,DA)=$P(DATA,"^",7)_"^"_$S('$P(DATA,"^",7):0,1:$J($P(DATA,"^",23)/$P(DATA,"^",7),0,3))_"^"_$P(DATA,"^",23)
;
; print report
S Y=DATESTRT D DD^%DT S DATESDT=Y,Y=DATEEND 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 DESCR="" F S DESCR=$O(^TMP($J,"PRCPRISP",DESCR)) Q:DESCR=""!($G(PRCPFLAG)) S ITEMDA=0 F S ITEMDA=$O(^TMP($J,"PRCPRISP",DESCR,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-6) D:SCREEN P^PRCPUREP Q:$D(PRCPFLAG) D H
. S ITEMDATA=$G(^PRCP(445,PRCP("I"),1,ITEMDA,0))
. W:'PRCPSUMM !,$E($$DESCR^PRCPUX1(PRCP("I"),ITEMDA),1,38),?39,"[",ITEMDA,"]"
. S (TOTALQI,TOTALVI)=0
. S DISTRPT="" F S DISTRPT=$O(^TMP($J,"PRCPRISP",DESCR,ITEMDA,DISTRPT)) Q:DISTRPT=""!($G(PRCPFLAG)) D
. . W:'PRCPSUMM !?15,$S(DISTRPT=" ":"<<NONE>>",1:DISTRPT)
. . S (TOTALQ,TOTALV)=0
. . S DATE=0 F S DATE=$O(^TMP($J,"PRCPRISP",DESCR,ITEMDA,DISTRPT,DATE)) Q:'DATE!($G(PRCPFLAG)) S DA=0 F S DA=$O(^TMP($J,"PRCPRISP",DESCR,ITEMDA,DISTRPT,DATE,DA)) Q:'DA!($G(PRCPFLAG)) S PRCPDATA=^(DA) D
. . . W:'PRCPSUMM ?40,$E(DATE,4,5),"/",$E(DATE,6,7),"/",$E(DATE,2,3),$J($P(PRCPDATA,"^"),10),$J($P(PRCPDATA,"^",2),10,3),$J($P(PRCPDATA,"^",3),12,2),!
. . . S TOTALQ=TOTALQ+$P(PRCPDATA,"^"),TOTALV=TOTALV+$P(PRCPDATA,"^",3)
. . . I $Y>(IOSL-6) D:SCREEN P^PRCPUREP Q:$D(PRCPFLAG) D H W !
. . I $G(PRCPFLAG) Q
. . S TOTALQI=TOTALQI+TOTALQ,TOTALVI=TOTALVI+TOTALV
. . S ^TMP($J,"PRCPRISP TOT",DISTRPT)=$G(^TMP($J,"PRCPRISP TOT",DISTRPT))+TOTALV
. . I 'PRCPSUMM W:$X>20 ! W ?27,"TOTALS BY RECIPIENT: ",$J(TOTALQ,10),$J(TOTALV,22,2)
. I $G(PRCPFLAG) Q
. W:'PRCPSUMM !?32,"TOTALS BY ITEM: ",$J(TOTALQI,10),$J(TOTALVI,22,2)
I $G(PRCPFLAG) D Q Q
I $Y>(IOSL-8) D:SCREEN P^PRCPUREP Q:$D(PRCPFLAG) D H
W !!,"TOTAL SALES TO RECIPIENTS:"
S TOTALV=0,DISTRPT="" F S DISTRPT=$O(^TMP($J,"PRCPRISP TOT",DISTRPT)) Q:DISTRPT=""!($G(PRCPFLAG)) S %=$G(^(DISTRPT)) D
. W !?10,DISTRPT,?40,$J(%,20,2)
. S TOTALV=TOTALV+%
. I $Y>(IOSL-4) D:SCREEN P^PRCPUREP Q:$D(PRCPFLAG) D H
I $G(PRCPFLAG) D Q Q
W !?10,"TOTAL",?40,$J(TOTALV,20,2)
D END^PRCPUREP
Q D ^%ZISC K ^TMP($J,"PRCPURS3"),^TMP($J,"PRCPRISP"),^TMP($J,"PRCPRISP TOT")
Q
;
H S %=NOW_" PAGE "_PAGE,PAGE=PAGE+1 I PAGE'=2!(SCREEN) W @IOF
W $C(13),"INVENTORY SALES FOR: ",$E(PRCP("IN"),1,20),?(80-$L(%)),%
W !?5,"INVENTORY SALES DATE RANGE: ",DATESDT," TO ",DATEEDT
S %="",$P(%,"-",81)=""
I PRCPSUMM W !?1,"*** ONLY SUMMARY OF SALES PRINTED ***",!,% Q
W !,"DESCRIPTION",?37,"DATE ISSUED",$J("QUANTITY",10),$J("SELL COST",10),$J("TOTAL VALUE",12),!,%
Q
;
TOWHOM(INVPT) ; identify a recipient
;
;
N DIC,DIR,PRCPA,PRCPB,PRCPC,PRCPD,PRCPI
TOWHOM1 S DIR(0)="FOU^3:50"
S DIR("A")="RECIPIENT"
D ^DIR K DIR
I $G(DUOUT)!$G(DTOUT)!(Y']"") G TOWHOMQ
S PRCPI=0,PRCPB=X
I $O(^PRCP(445.2,"D",INVPT,X,"")) S PRCPD(1)=X,PRCPI=1
S PRCPA=X
F PRCPC=PRCPI:1 S PRCPA=$O(^PRCP(445.2,"D",INVPT,PRCPA)) Q:$E(PRCPA,1,$L(PRCPB))'=PRCPB!(PRCPA']"") S PRCPD(PRCPC+1)=PRCPA
I '$O(PRCPD("")) W !,"THERE ARE NO RECIPIENTS OF THAT NAME IN THIS INVENTORY POINT" G TOWHOM1
F PRCPI=1:1:PRCPC S DIR("A",PRCPI)=$E(" ",$L(PRCPI+1),4)_PRCPI_" "_PRCPD(PRCPI)
S DIR("A")="WHICH RECIPIENT"
S DIR(0)="L^1:"_PRCPI
D ^DIR K DIR
TOWHOMQ Q ($S($G(DUOUT):"^",$G(DTOUT):"^",Y<1:0,Y="^":0,1:$G(PRCPD(+Y))))
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPRCPRISS 5582 printed Dec 13, 2024@02:15:02 Page 2
PRCPRISS ;WISC/RFJ-inventory sales (secondary) ;24 May 93
V ;;5.1;IFCAP;**1,41**;Oct 20, 2000
+1 ;Per VHA Directive 10-93-142, this routine should not be modified.
+2 QUIT
+3 ;
+4 ;
+5 ; inventory sales report
SECOND NEW ANS,DATEEND,DATESTRT,DISTRALL,PRCPEND,PRCPSTRT,PRCPSUMM,X
+1 KILL X
SET X(1)="The Inventory Sales Report will display all sales from the Secondary inventory point. This report is sorted by description, the recipient and the date issued."
DO DISPLAY^PRCPUX2(40,79,.X)
+2 ;
+3 KILL X
SET X(1)="Select the RECIPIENTS to display"
DO DISPLAY^PRCPUX2(2,40,.X)
+4 DO DISTRSEL^PRCPURS3(PRCP("I"))
+5 IF '$GET(DISTRALL)
IF $ORDER(^TMP($JOB,"PRCPURS3","YES",0))']""
WRITE !,"*** NO RECIPIENTS SELECTED !"
DO Q
QUIT
+6 ;
+7 KILL X
SET X(1)="Select the range of ISSUE DATES to display"
WRITE !!
DO DISPLAY^PRCPUX2(2,40,.X)
+8 DO DATESEL^PRCPURS2("Issue")
IF '$GET(DATEEND)
DO Q
QUIT
+9 ;
+10 SET PRCPSUMM=$$SUMMARY^PRCPURS0
IF PRCPSUMM<0
DO Q
QUIT
+11 ;
+12 WRITE !
SET %ZIS="Q"
DO ^%ZIS
if POP
GOTO Q
IF $DATA(IO("Q"))
Begin DoDot:1
+13 SET ZTDESC="Secondary Inventory Sales Report"
SET ZTRTN="DQ^PRCPRISS"
+14 SET ZTSAVE("PRCP*")=""
SET ZTSAVE("DATE*")=""
SET ZTSAVE("DISTRALL")=""
SET ZTSAVE("^TMP($J,""PRCPURS3"",")=""
SET ZTSAVE("ZTREQ")="@"
End DoDot:1
DO ^%ZTLOAD
KILL IO("Q"),ZTSK
DO Q
QUIT
+15 WRITE !!,"<*> please wait <*>"
+16 ;
+17 ; queue starts here
DQ NEW %,%H,%I,DA,DATA,DATE,DATEEDT,DATESDT,DESCR,DISTRNM,DISTRPT,ITEMDA,ITEMDATA,NOW,PAGE,PRCPDATA,PRCPFLAG,SCREEN,TOTALQ,TOTALQI,TOTALV,TOTALVI,X,Y
+1 KILL ^TMP($JOB,"PRCPRISP"),^TMP($JOB,"PRCPRISP TOT")
+2 SET DATE=DATESTRT-.01
FOR
SET DATE=$ORDER(^PRCP(445.2,"AX",PRCP("I"),DATE))
if 'DATE!(DATE>DATEEND)
QUIT
SET DA=0
FOR
SET DA=$ORDER(^PRCP(445.2,"AX",PRCP("I"),DATE,"U",DA))
if 'DA
QUIT
Begin DoDot:1
+3 SET DATA=$GET(^PRCP(445.2,DA,0))
IF DATA=""
QUIT
+4 SET ITEMDA=$PIECE(DATA,"^",5)
SET DESCR=$$DESCR^PRCPUX1(PRCP("I"),ITEMDA)
if DESCR=""
SET DESCR=" "
+5 SET DISTRPT=$PIECE($GET(^PRCP(445.2,DA,2)),"^",2)
+6 IF DISTRPT']""
IF '$GET(DISTRALL)
QUIT
+7 IF $GET(DISTRALL)
IF $DATA(^TMP($JOB,"PRCPURS3","NO",DISTRPT))
QUIT
+8 IF '$GET(DISTRALL)
IF '$DATA(^TMP($JOB,"PRCPURS3","YES",DISTRPT))
QUIT
+9 SET $PIECE(DATA,"^",7)=-$PIECE(DATA,"^",7)
SET $PIECE(DATA,"^",23)=-$PIECE(DATA,"^",23)
+10 IF '$PIECE(DATA,"^",23)
SET $PIECE(DATA,"^",23)=$JUSTIFY($PIECE(DATA,"^",7)*$PIECE(DATA,"^",8),0,2)
+11 SET ^TMP($JOB,"PRCPRISP",$EXTRACT(DESCR,1,10),ITEMDA,$EXTRACT(DISTRPT,1,24),DATE,DA)=$PIECE(DATA,"^",7)_"^"_$SELECT('$PIECE(DATA,"^",7):0,1:$JUSTIFY($PIECE(DATA,"^",23)/$PIECE(DATA,"^",7),0,3))_"^"_$PIECE(DATA,"^",23)
End DoDot:1
+12 ;
+13 ; print report
+14 SET Y=DATESTRT
DO DD^%DT
SET DATESDT=Y
SET Y=DATEEND
DO DD^%DT
SET DATEEDT=Y
+15 DO NOW^%DTC
SET Y=%
DO DD^%DT
SET NOW=Y
+16 SET PAGE=1
SET SCREEN=$$SCRPAUSE^PRCPUREP
USE IO
DO H
+17 SET DESCR=""
FOR
SET DESCR=$ORDER(^TMP($JOB,"PRCPRISP",DESCR))
if DESCR=""!($GET(PRCPFLAG))
QUIT
SET ITEMDA=0
FOR
SET ITEMDA=$ORDER(^TMP($JOB,"PRCPRISP",DESCR,ITEMDA))
if 'ITEMDA!($GET(PRCPFLAG))
QUIT
Begin DoDot:1
+18 IF $GET(ZTQUEUED)
IF $$S^%ZTLOAD
SET PRCPFLAG=1
WRITE !?10,"<<< TASKMANAGER JOB TERMINATED BY USER >>>"
QUIT
+19 IF $Y>(IOSL-6)
if SCREEN
DO P^PRCPUREP
if $DATA(PRCPFLAG)
QUIT
DO H
+20 SET ITEMDATA=$GET(^PRCP(445,PRCP("I"),1,ITEMDA,0))
+21 if 'PRCPSUMM
WRITE !,$EXTRACT($$DESCR^PRCPUX1(PRCP("I"),ITEMDA),1,38),?39,"[",ITEMDA,"]"
+22 SET (TOTALQI,TOTALVI)=0
+23 SET DISTRPT=""
FOR
SET DISTRPT=$ORDER(^TMP($JOB,"PRCPRISP",DESCR,ITEMDA,DISTRPT))
if DISTRPT=""!($GET(PRCPFLAG))
QUIT
Begin DoDot:2
+24 if 'PRCPSUMM
WRITE !?15,$SELECT(DISTRPT=" ":"<<NONE>>",1:DISTRPT)
+25 SET (TOTALQ,TOTALV)=0
+26 SET DATE=0
FOR
SET DATE=$ORDER(^TMP($JOB,"PRCPRISP",DESCR,ITEMDA,DISTRPT,DATE))
if 'DATE!($GET(PRCPFLAG))
QUIT
SET DA=0
FOR
SET DA=$ORDER(^TMP($JOB,"PRCPRISP",DESCR,ITEMDA,DISTRPT,DATE,DA))
if 'DA!($GET(PRCPFLAG))
QUIT
SET PRCPDATA=^(DA)
Begin DoDot:3
+27 if 'PRCPSUMM
WRITE ?40,$EXTRACT(DATE,4,5),"/",$EXTRACT(DATE,6,7),"/",$EXTRACT(DATE,2,3),$JUSTIFY($PIECE(PRCPDATA,"^"),10),$JUSTIFY($PIECE(PRCPDATA,"^",2),10,3),$JUSTIFY($PIECE(PRCPDATA,"^",3),12,2),!
+28 SET TOTALQ=TOTALQ+$PIECE(PRCPDATA,"^")
SET TOTALV=TOTALV+$PIECE(PRCPDATA,"^",3)
+29 IF $Y>(IOSL-6)
if SCREEN
DO P^PRCPUREP
if $DATA(PRCPFLAG)
QUIT
DO H
WRITE !
End DoDot:3
+30 IF $GET(PRCPFLAG)
QUIT
+31 SET TOTALQI=TOTALQI+TOTALQ
SET TOTALVI=TOTALVI+TOTALV
+32 SET ^TMP($JOB,"PRCPRISP TOT",DISTRPT)=$GET(^TMP($JOB,"PRCPRISP TOT",DISTRPT))+TOTALV
+33 IF 'PRCPSUMM
if $X>20
WRITE !
WRITE ?27,"TOTALS BY RECIPIENT: ",$JUSTIFY(TOTALQ,10),$JUSTIFY(TOTALV,22,2)
End DoDot:2
+34 IF $GET(PRCPFLAG)
QUIT
+35 if 'PRCPSUMM
WRITE !?32,"TOTALS BY ITEM: ",$JUSTIFY(TOTALQI,10),$JUSTIFY(TOTALVI,22,2)
End DoDot:1
+36 IF $GET(PRCPFLAG)
DO Q
QUIT
+37 IF $Y>(IOSL-8)
if SCREEN
DO P^PRCPUREP
if $DATA(PRCPFLAG)
QUIT
DO H
+38 WRITE !!,"TOTAL SALES TO RECIPIENTS:"
+39 SET TOTALV=0
SET DISTRPT=""
FOR
SET DISTRPT=$ORDER(^TMP($JOB,"PRCPRISP TOT",DISTRPT))
if DISTRPT=""!($GET(PRCPFLAG))
QUIT
SET %=$GET(^(DISTRPT))
Begin DoDot:1
+40 WRITE !?10,DISTRPT,?40,$JUSTIFY(%,20,2)
+41 SET TOTALV=TOTALV+%
+42 IF $Y>(IOSL-4)
if SCREEN
DO P^PRCPUREP
if $DATA(PRCPFLAG)
QUIT
DO H
End DoDot:1
+43 IF $GET(PRCPFLAG)
DO Q
QUIT
+44 WRITE !?10,"TOTAL",?40,$JUSTIFY(TOTALV,20,2)
+45 DO END^PRCPUREP
Q DO ^%ZISC
KILL ^TMP($JOB,"PRCPURS3"),^TMP($JOB,"PRCPRISP"),^TMP($JOB,"PRCPRISP TOT")
+1 QUIT
+2 ;
H SET %=NOW_" PAGE "_PAGE
SET PAGE=PAGE+1
IF PAGE'=2!(SCREEN)
WRITE @IOF
+1 WRITE $CHAR(13),"INVENTORY SALES FOR: ",$EXTRACT(PRCP("IN"),1,20),?(80-$LENGTH(%)),%
+2 WRITE !?5,"INVENTORY SALES DATE RANGE: ",DATESDT," TO ",DATEEDT
+3 SET %=""
SET $PIECE(%,"-",81)=""
+4 IF PRCPSUMM
WRITE !?1,"*** ONLY SUMMARY OF SALES PRINTED ***",!,%
QUIT
+5 WRITE !,"DESCRIPTION",?37,"DATE ISSUED",$JUSTIFY("QUANTITY",10),$JUSTIFY("SELL COST",10),$JUSTIFY("TOTAL VALUE",12),!,%
+6 QUIT
+7 ;
TOWHOM(INVPT) ; identify a recipient
+1 ;
+2 ;
+3 NEW DIC,DIR,PRCPA,PRCPB,PRCPC,PRCPD,PRCPI
TOWHOM1 SET DIR(0)="FOU^3:50"
+1 SET DIR("A")="RECIPIENT"
+2 DO ^DIR
KILL DIR
+3 IF $GET(DUOUT)!$GET(DTOUT)!(Y']"")
GOTO TOWHOMQ
+4 SET PRCPI=0
SET PRCPB=X
+5 IF $ORDER(^PRCP(445.2,"D",INVPT,X,""))
SET PRCPD(1)=X
SET PRCPI=1
+6 SET PRCPA=X
+7 FOR PRCPC=PRCPI:1
SET PRCPA=$ORDER(^PRCP(445.2,"D",INVPT,PRCPA))
if $EXTRACT(PRCPA,1,$LENGTH(PRCPB))'=PRCPB!(PRCPA']"")
QUIT
SET PRCPD(PRCPC+1)=PRCPA
+8 IF '$ORDER(PRCPD(""))
WRITE !,"THERE ARE NO RECIPIENTS OF THAT NAME IN THIS INVENTORY POINT"
GOTO TOWHOM1
+9 FOR PRCPI=1:1:PRCPC
SET DIR("A",PRCPI)=$EXTRACT(" ",$LENGTH(PRCPI+1),4)_PRCPI_" "_PRCPD(PRCPI)
+10 SET DIR("A")="WHICH RECIPIENT"
+11 SET DIR(0)="L^1:"_PRCPI
+12 DO ^DIR
KILL DIR
TOWHOMQ QUIT ($SELECT($GET(DUOUT):"^",$GET(DTOUT):"^",Y<1:0,Y="^":0,1:$GET(PRCPD(+Y))))