PSGWRAC ;BHAM ISC/CML-Print AOU Status for AMIS - Inpatient Site, Returns, and AMIS Count ; 19 Mar 93 / 8:35 AM
;;2.3; Automatic Replenishment/Ward Stock ;;4 JAN 94
D NOW^%DTC S PSGWDT=$P(%,".")
W !!,"This option prints a list of active AOUs displaying the following data:",!!?5,"1. INPATIENT SITE",!?5,"2. RETURNS CREDITED TO",!?5,"3. COUNT ON AMIS"
W !!,"Right margin for this report is 80 columns.",!,"You may queue the report to print at a later time.",!!
I '$O(^PSI(58.1,0)) W !,"You MUST create AOUs before running this report!" K %,%I,%H,PSGWDT Q
DEV K %ZIS,IOP S %ZIS="QM",%ZIS("B")="" D ^%ZIS I POP W !,"NO DEVICE SELECTED OR REPORT PRINTED!" G QUIT
I $D(IO("Q")) K IO("Q") S PSGWIO=ION,ZTIO="" K ZTSAVE,ZTDTH,ZTSK S ZTRTN="ENQ^PSGWRAC",ZTDESC="Compile Data for AOU AMIS Status Report",ZTSAVE("PSGWIO")="",ZTSAVE("PSGWDT")=""
I D ^%ZTLOAD,HOME^%ZIS K ZTSK G QUIT
U IO
;
ENQ ;ENTRY POINT WHEN QUEUED
AOU K ^TMP("PSGWRAC",$J) F AOU=0:0 S AOU=$O(^PSI(58.1,AOU)) G:('AOU)&($D(ZTQUEUED)) PRTQUE G:'AOU PRINT D BUILD
;
BUILD ;BUILD DATA ELEMENTS
I $D(^PSI(58.1,AOU,"I")),^("I"),^("I")'>DT Q
I $D(^PSI(58.1,AOU,0)) S LOC=^(0),AOUNM=$S($P(LOC,"^")]"":$P(LOC,"^"),1:"AOU NAME MISSING"),RET=$S($P(LOC,"^",2)="A":"AR",$P(LOC,"^",2)="W":"WS",1:"N/A"),ACNT=$S(+$P(LOC,"^",3):"NO",$P(LOC,"^",3)="":"N/A",1:"YES") D SETGL
Q
SETGL ;
S SITE="" I $D(^PSI(58.1,AOU,"SITE")) S SITE=^("SITE") I SITE,$D(^PS(59.4,SITE,0)),$P(^(0),"^")]"" S SITE=$P(^(0),"^")
S SITE=$S(+SITE:"ZZSITE",SITE="":"ZZSITE",1:SITE),^TMP("PSGWRAC",$J,SITE,AOUNM)=RET_"^"_ACNT
Q
;
PRTQUE ;AFTER DATA IS COMPILED, QUEUE THE PRINT
K ZTSAVE,ZTIO S ZTIO=PSGWIO,ZTRTN="PRINT^PSGWRAC",ZTDESC="Print AOU Status for AMIS",ZTDTH=$H,ZTSAVE("^TMP(""PSGWRAC"",$J,")=""
D ^%ZTLOAD K ^TMP("PSGWRAC",$J) G QUIT
PRINT ;
S $P(LN,"-",80)="",PG=0,%DT="",(SITE,AOUNM,QFLG)="",X="T" D ^%DT X ^DD("DD") S HDT=Y D HDR
I '$D(^TMP("PSGWRAC",$J)) W !?17,"***** NO DATA AVAILABLE FOR THIS REPORT *****" G QUIT
F LL=0:0 S SITE=$O(^TMP("PSGWRAC",$J,SITE)) Q:QFLG!(SITE="") F LL=0:0 S AOUNM=$O(^TMP("PSGWRAC",$J,SITE,AOUNM)) Q:AOUNM="" S RET=$P(^TMP("PSGWRAC",$J,SITE,AOUNM),"^"),ACNT=$P(^(AOUNM),"^",2) D WRTDATA Q:QFLG
DONE I $E(IOST)'="C" W @IOF
I $E(IOST)="C" D:'QFLG SS^PSGWUTL1
QUIT ;
K %,%H,%I,%DT,PSGWIO,ACNT,AOU,AOUNM,HDT,LL,LN,LOC,PG,PSGWDT,RET,SITE,X,Y,ZTSK,ZTIO,DA,IO("Q"),ANS,QFLG
K ^TMP("PSGWRAC",$J) D ^%ZISC
S:$D(ZTQUEUED) ZTREQ="@" Q
WRTDATA ;DATA LINES
D:$Y+5>IOSL PRTCHK Q:QFLG W !,AOUNM,?31,$S(SITE="ZZSITE":"NONE LISTED",1:SITE),?64,RET,?74,ACNT
Q
HDR ;HEADER
W:$Y @IOF S PG=PG+1 W !?22,"AOU LISTING - RETURNS AND AMIS COUNT",?70,"PAGE: ",PG,!?31,"PRINTED: ",HDT,!!?74,"COUNT",!?62,"RETURNS",?74,"ON",!,"AREA OF USE (AOU)",?33,"INPATIENT SITE",?60,"CREDITED TO AMIS?",!,LN
Q
PRTCHK ;
I $E(IOST)="C" W !!,"Press <RETURN> to Continue or ""^"" to Exit: " R ANS:DTIME S:'$T ANS="^" D:ANS?1."?" HELP^PSGWUTL1 I ANS="^" S QFLG=1 Q
D HDR Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPSGWRAC 2968 printed Nov 22, 2024@16:50:16 Page 2
PSGWRAC ;BHAM ISC/CML-Print AOU Status for AMIS - Inpatient Site, Returns, and AMIS Count ; 19 Mar 93 / 8:35 AM
+1 ;;2.3; Automatic Replenishment/Ward Stock ;;4 JAN 94
+2 DO NOW^%DTC
SET PSGWDT=$PIECE(%,".")
+3 WRITE !!,"This option prints a list of active AOUs displaying the following data:",!!?5,"1. INPATIENT SITE",!?5,"2. RETURNS CREDITED TO",!?5,"3. COUNT ON AMIS"
+4 WRITE !!,"Right margin for this report is 80 columns.",!,"You may queue the report to print at a later time.",!!
+5 IF '$ORDER(^PSI(58.1,0))
WRITE !,"You MUST create AOUs before running this report!"
KILL %,%I,%H,PSGWDT
QUIT
DEV KILL %ZIS,IOP
SET %ZIS="QM"
SET %ZIS("B")=""
DO ^%ZIS
IF POP
WRITE !,"NO DEVICE SELECTED OR REPORT PRINTED!"
GOTO QUIT
+1 IF $DATA(IO("Q"))
KILL IO("Q")
SET PSGWIO=ION
SET ZTIO=""
KILL ZTSAVE,ZTDTH,ZTSK
SET ZTRTN="ENQ^PSGWRAC"
SET ZTDESC="Compile Data for AOU AMIS Status Report"
SET ZTSAVE("PSGWIO")=""
SET ZTSAVE("PSGWDT")=""
+2 IF $TEST
DO ^%ZTLOAD
DO HOME^%ZIS
KILL ZTSK
GOTO QUIT
+3 USE IO
+4 ;
ENQ ;ENTRY POINT WHEN QUEUED
AOU KILL ^TMP("PSGWRAC",$JOB)
FOR AOU=0:0
SET AOU=$ORDER(^PSI(58.1,AOU))
if ('AOU)&($DATA(ZTQUEUED))
GOTO PRTQUE
if 'AOU
GOTO PRINT
DO BUILD
+1 ;
BUILD ;BUILD DATA ELEMENTS
+1 IF $DATA(^PSI(58.1,AOU,"I"))
IF ^("I")
IF ^("I")'>DT
QUIT
+2 IF $DATA(^PSI(58.1,AOU,0))
SET LOC=^(0)
SET AOUNM=$SELECT($PIECE(LOC,"^")]"":$PIECE(LOC,"^"),1:"AOU NAME MISSING")
SET RET=$SELECT($PIECE(LOC,"^",2)="A":"AR",$PIECE(LOC,"^",2)="W":"WS",1:"N/A")
SET ACNT=$SELECT(+$PIECE(LOC,"^",3):"NO",$PIECE(LOC,"^",3)="":"N/A",1:"YES")
DO SETGL
+3 QUIT
SETGL ;
+1 SET SITE=""
IF $DATA(^PSI(58.1,AOU,"SITE"))
SET SITE=^("SITE")
IF SITE
IF $DATA(^PS(59.4,SITE,0))
IF $PIECE(^(0),"^")]""
SET SITE=$PIECE(^(0),"^")
+2 SET SITE=$SELECT(+SITE:"ZZSITE",SITE="":"ZZSITE",1:SITE)
SET ^TMP("PSGWRAC",$JOB,SITE,AOUNM)=RET_"^"_ACNT
+3 QUIT
+4 ;
PRTQUE ;AFTER DATA IS COMPILED, QUEUE THE PRINT
+1 KILL ZTSAVE,ZTIO
SET ZTIO=PSGWIO
SET ZTRTN="PRINT^PSGWRAC"
SET ZTDESC="Print AOU Status for AMIS"
SET ZTDTH=$HOROLOG
SET ZTSAVE("^TMP(""PSGWRAC"",$J,")=""
+2 DO ^%ZTLOAD
KILL ^TMP("PSGWRAC",$JOB)
GOTO QUIT
PRINT ;
+1 SET $PIECE(LN,"-",80)=""
SET PG=0
SET %DT=""
SET (SITE,AOUNM,QFLG)=""
SET X="T"
DO ^%DT
XECUTE ^DD("DD")
SET HDT=Y
DO HDR
+2 IF '$DATA(^TMP("PSGWRAC",$JOB))
WRITE !?17,"***** NO DATA AVAILABLE FOR THIS REPORT *****"
GOTO QUIT
+3 FOR LL=0:0
SET SITE=$ORDER(^TMP("PSGWRAC",$JOB,SITE))
if QFLG!(SITE="")
QUIT
FOR LL=0:0
SET AOUNM=$ORDER(^TMP("PSGWRAC",$JOB,SITE,AOUNM))
if AOUNM=""
QUIT
SET RET=$PIECE(^TMP("PSGWRAC",$JOB,SITE,AOUNM),"^")
SET ACNT=$PIECE(^(AOUNM),"^",2)
DO WRTDATA
if QFLG
QUIT
DONE IF $EXTRACT(IOST)'="C"
WRITE @IOF
+1 IF $EXTRACT(IOST)="C"
if 'QFLG
DO SS^PSGWUTL1
QUIT ;
+1 KILL %,%H,%I,%DT,PSGWIO,ACNT,AOU,AOUNM,HDT,LL,LN,LOC,PG,PSGWDT,RET,SITE,X,Y,ZTSK,ZTIO,DA,IO("Q"),ANS,QFLG
+2 KILL ^TMP("PSGWRAC",$JOB)
DO ^%ZISC
+3 if $DATA(ZTQUEUED)
SET ZTREQ="@"
QUIT
WRTDATA ;DATA LINES
+1 if $Y+5>IOSL
DO PRTCHK
if QFLG
QUIT
WRITE !,AOUNM,?31,$SELECT(SITE="ZZSITE":"NONE LISTED",1:SITE),?64,RET,?74,ACNT
+2 QUIT
HDR ;HEADER
+1 if $Y
WRITE @IOF
SET PG=PG+1
WRITE !?22,"AOU LISTING - RETURNS AND AMIS COUNT",?70,"PAGE: ",PG,!?31,"PRINTED: ",HDT,!!?74,"COUNT",!?62,"RETURNS",?74,"ON",!,"AREA OF USE (AOU)",?33,"INPATIENT SITE",?60,"CREDITED TO AMIS?",!,LN
+2 QUIT
PRTCHK ;
+1 IF $EXTRACT(IOST)="C"
WRITE !!,"Press <RETURN> to Continue or ""^"" to Exit: "
READ ANS:DTIME
if '$TEST
SET ANS="^"
if ANS?1."?"
DO HELP^PSGWUTL1
IF ANS="^"
SET QFLG=1
QUIT
+2 DO HDR
QUIT