PSGAMS0 ;BIR/CML3-PRINT AMIS REPORT ;09 JUL 94 / 10:42 AM
;;5.0; INPATIENT MEDICATIONS ;;16 DEC 97
START ;
D NOW^%DTC S PSGDT=%,PSGPDT=$$ENDTC^PSGMI(PSGDT),CML=IO'=IO(0)!(IOST'["C-"),(NP,LN1,LN2)="",$P(LN1,"-",81)="",$P(LN2,"=",81)="",(TCNT,TCST)=0
U IO D HDR I '$D(^UTILITY("PSG",$J)) W !!?27,"*** NO AMIS DATA FOUND ***" G DONE
;
RUN ;
S WN="" F S WN=$O(^UTILITY("PSG",$J,WN)) Q:WN="" S CST=^(WN) D:$Y+3>IOSL NP G:NP["^" DONE D WRITE
;
TOTLS ;
D:$Y+4>IOSL NP I NP'["^" S TCPU=$S(TCNT:TCST/TCNT,1:0) S:TCST<0&(TCPU>0) TCPU=-TCPU W !,LN2,!!?15,"TOTALS =>",?35,$J(TCNT,9,0),?52,$J(TCST,12,2),?72,$J(TCPU,6,2)
;
DONE ;
W:CML&($Y) @IOF,@IOF K %,%H,%I,CML,CNT,CPU,CST,LN1,LN2,NP,PSGPDT,TCNT,TCPU,TCST Q
;
WRITE ;
S CNT=+CST,CST=$P(CST,"^",2),TCNT=TCNT+CNT,TCST=TCST+CST,CPU=$S(CNT:CST/CNT,1:0) S:CST<0&(CPU>0) CPU=-CPU W !?2,WN,?35,$J(CNT,9,0),?52,$J(CST,12,2),?72,$J(CPU,6,2),! Q
;
NP ;
I 'CML W $C(7) R !,"'^' TO STOP ",NP:DTIME W:'$T $C(7) S:'$T NP="^" Q:NP["^"
;
HDR ;
W:$Y @IOF W !!?30,"UNIT DOSE AMIS REPORT",?63,PSGPDT,!?25,"FROM ",STRT," THROUGH ",STOP,!!?35,"TOTAL UNITS",?56,"TOTAL",?68,"AVERAGE COST",!?10,"WARD",?36,"DISPENSED",?56,"COST",?70,"PER UNIT",!,LN1,! Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPSGAMS0 1212 printed Oct 16, 2024@18:01:31 Page 2
PSGAMS0 ;BIR/CML3-PRINT AMIS REPORT ;09 JUL 94 / 10:42 AM
+1 ;;5.0; INPATIENT MEDICATIONS ;;16 DEC 97
START ;
+1 DO NOW^%DTC
SET PSGDT=%
SET PSGPDT=$$ENDTC^PSGMI(PSGDT)
SET CML=IO'=IO(0)!(IOST'["C-")
SET (NP,LN1,LN2)=""
SET $PIECE(LN1,"-",81)=""
SET $PIECE(LN2,"=",81)=""
SET (TCNT,TCST)=0
+2 USE IO
DO HDR
IF '$DATA(^UTILITY("PSG",$JOB))
WRITE !!?27,"*** NO AMIS DATA FOUND ***"
GOTO DONE
+3 ;
RUN ;
+1 SET WN=""
FOR
SET WN=$ORDER(^UTILITY("PSG",$JOB,WN))
if WN=""
QUIT
SET CST=^(WN)
if $Y+3>IOSL
DO NP
if NP["^"
GOTO DONE
DO WRITE
+2 ;
TOTLS ;
+1 if $Y+4>IOSL
DO NP
IF NP'["^"
SET TCPU=$SELECT(TCNT:TCST/TCNT,1:0)
if TCST<0&(TCPU>0)
SET TCPU=-TCPU
WRITE !,LN2,!!?15,"TOTALS =>",?35,$JUSTIFY(TCNT,9,0),?52,$JUSTIFY(TCST,12,2),?72,$JUSTIFY(TCPU,6,2)
+2 ;
DONE ;
+1 if CML&($Y)
WRITE @IOF,@IOF
KILL %,%H,%I,CML,CNT,CPU,CST,LN1,LN2,NP,PSGPDT,TCNT,TCPU,TCST
QUIT
+2 ;
WRITE ;
+1 SET CNT=+CST
SET CST=$PIECE(CST,"^",2)
SET TCNT=TCNT+CNT
SET TCST=TCST+CST
SET CPU=$SELECT(CNT:CST/CNT,1:0)
if CST<0&(CPU>0)
SET CPU=-CPU
WRITE !?2,WN,?35,$JUSTIFY(CNT,9,0),?52,$JUSTIFY(CST,12,2),?72,$JUSTIFY(CPU,6,2),!
QUIT
+2 ;
NP ;
+1 IF 'CML
WRITE $CHAR(7)
READ !,"'^' TO STOP ",NP:DTIME
if '$TEST
WRITE $CHAR(7)
if '$TEST
SET NP="^"
if NP["^"
QUIT
+2 ;
HDR ;
+1 if $Y
WRITE @IOF
WRITE !!?30,"UNIT DOSE AMIS REPORT",?63,PSGPDT,!?25,"FROM ",STRT," THROUGH ",STOP,!!?35,"TOTAL UNITS",?56,"TOTAL",?68,"AVERAGE COST",!?10,"WARD",?36,"DISPENSED",?56,"COST",?70,"PER UNIT",!,LN1,!
QUIT