PSDAMIS4 ;BIR/JPW-Print NAOU AMIS Summary Totals ; 1 Sept 94
;;3.0; CONTROLLED SUBSTANCES ;;13 Feb 97
PRINT ;prints data for stock drugs
K LN S $P(LN,"-",80)="",(PG,PSDOUT)=0,%DT="",X="T" D ^%DT X ^DD("DD") S RPDT=Y
I '$D(^TMP("PSDAMIS",$J)) D HDR W !!,?10,"***** NO DATA AVAILABLE FOR THIS REPORT *****" Q
S JJ="" F S JJ=$O(^TMP("PSDAMISS",$J,JJ)) D:JJ="" GTOT Q:JJ=""!(PSDOUT) D HDR Q:PSDOUT S KK="" F S KK=$O(^TMP("PSDAMISS",$J,JJ,KK)) D:KK="" NTOT Q:KK=""!(PSDOUT) D TOT
Q
HDR ;lists header information
Q:PSDOUT
I $E(IOST,1,2)="C-",PG K DA,DIR S DIR(0)="E" D ^DIR K DIR I 'Y S PSDOUT=1 Q
W:$Y @IOF S PG=PG+1 W !,"SUMMARY NAOU/DRUG USAGE REPORT - DATE: "_RPDT,?70,"PAGE: ",PG,!
I ANS="N",$D(JJ) W "NAOU: ",JJ,!
I ANS="D",$D(JJ) W "DRUG: ",JJ,!
W "From ",$P(PSDATE,"^")," to ",$P(PSDATE,"^",2),!!
W !,?2,"=> ",$S(ANS="D":"NAOU",1:"DRUG"),!,"TOTAL # OF ORDERS",?30,"TOTAL QUANTITY",?60,"TOTAL COST",!,LN,!
Q
TOT Q:PSDOUT I $Y+8>IOSL D HDR Q:PSDOUT
W !!,?2,"=> ",KK,!,$J(^TMP("PSDAMISS",$J,JJ,KK),8),?30,$J(^TMP("PSDAMISQ",$J,JJ,KK),8),?60,$J(^TMP("PSDAMISC",$J,JJ,KK),8,2)
Q
NTOT Q:PSDOUT I $Y+8>IOSL D HDR Q:PSDOUT
W !!,?2,"=> ",KK
W !!,$S(ANS="D":"DRUG",1:"NAOU")," Subtotals: ",!,"Number of Orders: ",?30,$J(^TMP("PSDAMIST",$J,JJ),8),! W:ANS="D" "Total Quantity: ",?30,$J(^TMP("PSDAMISQT",$J,JJ),8),!
W "Total Cost of Orders: ",?60,$J(^TMP("PSDAMISCN",$J,JJ),8,2)
W !,"Average Cost of Orders: ",?60,$S(+^TMP("PSDAMIST",$J,JJ):$J((^TMP("PSDAMISCN",$J,JJ)/^TMP("PSDAMIST",$J,JJ)),8,2),1:$J("0.00",8,2)),!
Q
GTOT ;grand totals
Q:PSDOUT D HDR Q:PSDOUT
W !,"Grand Totals by Dispensing Site: ",PSDSN,!
S PSDSN="" F S PSDSN=$O(^TMP("PSDAMISVG",$J,PSDSN)) Q:PSDSN=""!PSDOUT D Q:PSDOUT
.I $Y+6>IOSL D HDR Q:PSDOUT
.W !,"Number of Orders: ",?30,$J(^TMP("PSDAMISVG",$J,PSDSN),6),!,"Cost of Orders: ",?60,$J(^TMP("PSDAMISCVG",$J,PSDSN),8,2),!
.W "Average Cost Per Order: ",?60,$S(+^TMP("PSDAMISVG",$J,PSDSN):$J((^TMP("PSDAMISCVG",$J,PSDSN)/^TMP("PSDAMISVG",$J,PSDSN)),8,2),1:$J("0.00",8,2)),!
D HDR Q:PSDOUT
W !!,"Grand Totals: ",!,"Number of Orders: ",?30,$J(^TMP("PSDAMISG",$J),8),!,"Cost of Orders: ",?60,$J(^TMP("PSDAMISCG",$J),8,2),!
W "Average Cost Per Order: ",?60,$J((^TMP("PSDAMISCG",$J)/^TMP("PSDAMISG",$J)),8,2),!
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPSDAMIS4 2300 printed Dec 13, 2024@01:45:05 Page 2
PSDAMIS4 ;BIR/JPW-Print NAOU AMIS Summary Totals ; 1 Sept 94
+1 ;;3.0; CONTROLLED SUBSTANCES ;;13 Feb 97
PRINT ;prints data for stock drugs
+1 KILL LN
SET $PIECE(LN,"-",80)=""
SET (PG,PSDOUT)=0
SET %DT=""
SET X="T"
DO ^%DT
XECUTE ^DD("DD")
SET RPDT=Y
+2 IF '$DATA(^TMP("PSDAMIS",$JOB))
DO HDR
WRITE !!,?10,"***** NO DATA AVAILABLE FOR THIS REPORT *****"
QUIT
+3 SET JJ=""
FOR
SET JJ=$ORDER(^TMP("PSDAMISS",$JOB,JJ))
if JJ=""
DO GTOT
if JJ=""!(PSDOUT)
QUIT
DO HDR
if PSDOUT
QUIT
SET KK=""
FOR
SET KK=$ORDER(^TMP("PSDAMISS",$JOB,JJ,KK))
if KK=""
DO NTOT
if KK=""!(PSDOUT)
QUIT
DO TOT
+4 QUIT
HDR ;lists header information
+1 if PSDOUT
QUIT
+2 IF $EXTRACT(IOST,1,2)="C-"
IF PG
KILL DA,DIR
SET DIR(0)="E"
DO ^DIR
KILL DIR
IF 'Y
SET PSDOUT=1
QUIT
+3 if $Y
WRITE @IOF
SET PG=PG+1
WRITE !,"SUMMARY NAOU/DRUG USAGE REPORT - DATE: "_RPDT,?70,"PAGE: ",PG,!
+4 IF ANS="N"
IF $DATA(JJ)
WRITE "NAOU: ",JJ,!
+5 IF ANS="D"
IF $DATA(JJ)
WRITE "DRUG: ",JJ,!
+6 WRITE "From ",$PIECE(PSDATE,"^")," to ",$PIECE(PSDATE,"^",2),!!
+7 WRITE !,?2,"=> ",$SELECT(ANS="D":"NAOU",1:"DRUG"),!,"TOTAL # OF ORDERS",?30,"TOTAL QUANTITY",?60,"TOTAL COST",!,LN,!
+8 QUIT
TOT if PSDOUT
QUIT
IF $Y+8>IOSL
DO HDR
if PSDOUT
QUIT
+1 WRITE !!,?2,"=> ",KK,!,$JUSTIFY(^TMP("PSDAMISS",$JOB,JJ,KK),8),?30,$JUSTIFY(^TMP("PSDAMISQ",$JOB,JJ,KK),8),?60,$JUSTIFY(^TMP("PSDAMISC",$JOB,JJ,KK),8,2)
+2 QUIT
NTOT if PSDOUT
QUIT
IF $Y+8>IOSL
DO HDR
if PSDOUT
QUIT
+1 WRITE !!,?2,"=> ",KK
+2 WRITE !!,$SELECT(ANS="D":"DRUG",1:"NAOU")," Subtotals: ",!,"Number of Orders: ",?30,$JUSTIFY(^TMP("PSDAMIST",$JOB,JJ),8),!
if ANS="D"
WRITE "Total Quantity: ",?30,$JUSTIFY(^TMP("PSDAMISQT",$JOB,JJ),8),!
+3 WRITE "Total Cost of Orders: ",?60,$JUSTIFY(^TMP("PSDAMISCN",$JOB,JJ),8,2)
+4 WRITE !,"Average Cost of Orders: ",?60,$SELECT(+^TMP("PSDAMIST",$JOB,JJ):$JUSTIFY((^TMP("PSDAMISCN",$JOB,JJ)/^TMP("PSDAMIST",$JOB,JJ)),8,2),1:$JUSTIFY("0.00",8,2)),!
+5 QUIT
GTOT ;grand totals
+1 if PSDOUT
QUIT
DO HDR
if PSDOUT
QUIT
+2 WRITE !,"Grand Totals by Dispensing Site: ",PSDSN,!
+3 SET PSDSN=""
FOR
SET PSDSN=$ORDER(^TMP("PSDAMISVG",$JOB,PSDSN))
if PSDSN=""!PSDOUT
QUIT
Begin DoDot:1
+4 IF $Y+6>IOSL
DO HDR
if PSDOUT
QUIT
+5 WRITE !,"Number of Orders: ",?30,$JUSTIFY(^TMP("PSDAMISVG",$JOB,PSDSN),6),!,"Cost of Orders: ",?60,$JUSTIFY(^TMP("PSDAMISCVG",$JOB,PSDSN),8,2),!
+6 WRITE "Average Cost Per Order: ",?60,$SELECT(+^TMP("PSDAMISVG",$JOB,PSDSN):$JUSTIFY((^TMP("PSDAMISCVG",$JOB,PSDSN)/^TMP("PSDAMISVG",$JOB,PSDSN)),8,2),1:$JUSTIFY("0.00",8,2)),!
End DoDot:1
if PSDOUT
QUIT
+7 DO HDR
if PSDOUT
QUIT
+8 WRITE !!,"Grand Totals: ",!,"Number of Orders: ",?30,$JUSTIFY(^TMP("PSDAMISG",$JOB),8),!,"Cost of Orders: ",?60,$JUSTIFY(^TMP("PSDAMISCG",$JOB),8,2),!
+9 WRITE "Average Cost Per Order: ",?60,$JUSTIFY((^TMP("PSDAMISCG",$JOB)/^TMP("PSDAMISG",$JOB)),8,2),!
+10 QUIT