PSGWODP ;BHAM ISC/PTD,CML-Print an On-Demand Report by Date/AOU ;Oct 17, 2017@14:48
;;2.3;Automatic Replenishment/Ward Stock;**18,19**;4 JAN 94;Build 45
;
BDT S %DT="AEXT",%DT("A")="BEGINNING date for report: " D ^%DT K %DT G:Y<0 END S BDT=Y,BDT=BDT-.00001
N PSGWPFLG S PSGWPFLG=0 I $$GET^XPAR("ALL","PSGW_WS_LVL_ON") S PSGWPFLG=1 ; Patch PSGW*2.3*19 are changes active
EDT S %DT="AEXT",%DT(0)=BDT,%DT("A")="ENDING date for report: " D ^%DT K %DT G:Y<0 END S EDT=Y S:EDT'["." EDT=EDT+.24
I PSGWPFLG S EDT=EDT+.00001
EN D SEL^PSGWUTL1 G:'$D(SEL) END G:SEL="I" EN2
ASKAOU ;
F JJ=0:0 S DIC="^PSI(58.1,",DIC(0)="QEAM" D ^DIC K DIC Q:Y<0 S AOULP(+Y)=""
I '$D(AOULP)&(X'="^ALL") G END
I X="^ALL" F AOU=0:0 S AOU=$O(^PSI(58.1,AOU)) Q:'AOU S AOULP(AOU)=""
EN2 G:'$D(AOULP) END W !!,"The right margin for this report is 80.",!,"You may queue the report to print at a later time.",!!
DEV K %ZIS,IOP S %ZIS="QM",%ZIS("B")="" D ^%ZIS I POP W !,"NO DEVICE SELECTED OR REPORT PRINTED!" G END
I $D(IO("Q")) K IO("Q") S ZTRTN="ENQ^PSGWODP",ZTDESC="Print On-Demand Request" S:$D(AOULP) ZTSAVE("AOULP(")="" F G="BDT","EDT","SEL","IGDA" S:$D(@G) ZTSAVE(G)=""
I D ^%ZTLOAD,HOME^%ZIS K ZTSK G END
U IO
;
ENQ ;ENTRY POINT WHEN QUEUED
I '$D(PSGWPFLG) N PSGWPFLG S PSGWPFLG=0 I $$GET^XPAR("ALL","PSGW_WS_LVL_ON") S PSGWPFLG=1 ; Patch PSGW*2.3*19 are changes active
K ^TMP("PSGWOD",$J) S AOU=0
AOU I $D(AOULP) S AOU=$O(AOULP(AOU)) I 'AOU D PRINT^PSGWODPR G DONE
I '$D(AOULP) S AOU=$O(^PSI(58.1,AOU)) I 'AOU D PRINT^PSGWODPR G DONE
DRUG ;LOOP THROUGH DRUGS FOR AOU
S DRGDA=0
DRGLP S DRGDA=$O(^PSI(58.1,AOU,1,DRGDA)) G:'DRGDA AOU D OD G DRGLP
;
OD ;ON DEMAND REQUESTS
Q:'$O(^PSI(58.1,AOU,1,DRGDA,5,0)) S ODA=0
ODLP S ODA=$O(^PSI(58.1,AOU,1,DRGDA,5,ODA)) Q:'ODA S LOC=^(ODA,0),ODT=$P(LOC,"^") I (ODT<BDT)!(ODT>EDT) G ODLP
S QD=$P(LOC,"^",2),EDUZ=$S($P(LOC,"^",3)'="":$P(LOC,"^",3),1:"NOT LISTED"),DRGNM=$P(^PSI(58.1,AOU,1,DRGDA,0),"^"),STAN=$S($P(^(0),"^",3)="":0,$P(^(0),"^",3)>DT:0,1:1)
S LEDUZ=$S(+$P(LOC,"^",5):$P(LOC,"^",5),1:"N/A"),LEDT=$S(+$P(LOC,"^",6):$P(LOC,"^",6),1:"N/A") D BACKORD
I '$O(^PSDRUG(DRGNM,0)) S DIK="^PSI(58.1,"_AOU_",1,",DA=DRGDA,DA(1)=AOU D ^DIK K DIK G ODLP
I PSGWPFLG D
. N IEN S DRGNAME=$$GET1^DIQ(50,DRGNM,.01),IEN=DRGDA_","_AOU_","
. S ^TMP("PSGWOD",$J,"ARCHSTOCK",$P(ODT,"."),AOU,EDUZ,ODT,DRGNAME)=$$GET1^DIQ(58.11,IEN,1)
S DRGNAME=$P(^PSDRUG(DRGNM,0),"^"),^TMP("PSGWOD",$J,$P(ODT,"."),AOU,EDUZ,ODT,DRGNAME)=QD_"^"_STAN_"^"_DRGDA_"^"_BOTOT_"^"_LEDUZ_"^"_LEDT G ODLP
DONE I $E(IOST)'="C" W @IOF
I $E(IOST)="C" D:'QFLG SS^PSGWUTL1
END K EDITDT,PREV,ZTSK,^TMP("PSGWOD",$J),AOULP,JJ,ANS,AOU,BDT,DRGDA,DRGNAME,DRGNM,EDT,EDUZ,J,LEDT,LEDUZ,LOC,ODA,ODT,PGCT,QD,STAN,PSGDA,ADT,CAT,PSGWDT,PSGWODT,PSGWAOU,AMISFL,KEY,ODTM,TMDT,%,%I,%H,DA,G,D,DIE
K %DT,%W,C,SEL,IGDA,D0,D1,D2,DI,DIC,DIYS,DLAYGO,DQ,IO("Q"),PSGWV,BOTOT,X,Y,BO,QFLG,PSGWDUZ,PRTFLG,PSGWDT,PSGWCAT,BON,ALL,BCFLG,NEWI,PSGDR,PSGWADT,PSGWD,PSGWDN,PSGWPFLG D ^%ZISC
S:$D(ZTQUEUED) ZTREQ="@" Q
BACKORD ;TOTAL ANY BACKORDERS
S X=DRGNM,BOTOT=0,DIC="^PSI(58.3,",DIC(0)="" D ^DIC Q:Y<0 S BO=+Y F J=0:0 S J=$S($D(^PSI(58.3,BO,1,AOU,1,J)):$O(^(J)),1:"") Q:'J S:$S($P(^(J,0),"^",5)="":1,1:0) BOTOT=BOTOT+$P(^(0),"^",2)
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPSGWODP 3245 printed Oct 16, 2024@17:40:30 Page 2
PSGWODP ;BHAM ISC/PTD,CML-Print an On-Demand Report by Date/AOU ;Oct 17, 2017@14:48
+1 ;;2.3;Automatic Replenishment/Ward Stock;**18,19**;4 JAN 94;Build 45
+2 ;
BDT SET %DT="AEXT"
SET %DT("A")="BEGINNING date for report: "
DO ^%DT
KILL %DT
if Y<0
GOTO END
SET BDT=Y
SET BDT=BDT-.00001
+1 ; Patch PSGW*2.3*19 are changes active
NEW PSGWPFLG
SET PSGWPFLG=0
IF $$GET^XPAR("ALL","PSGW_WS_LVL_ON")
SET PSGWPFLG=1
EDT SET %DT="AEXT"
SET %DT(0)=BDT
SET %DT("A")="ENDING date for report: "
DO ^%DT
KILL %DT
if Y<0
GOTO END
SET EDT=Y
if EDT'["."
SET EDT=EDT+.24
+1 IF PSGWPFLG
SET EDT=EDT+.00001
EN DO SEL^PSGWUTL1
if '$DATA(SEL)
GOTO END
if SEL="I"
GOTO EN2
ASKAOU ;
+1 FOR JJ=0:0
SET DIC="^PSI(58.1,"
SET DIC(0)="QEAM"
DO ^DIC
KILL DIC
if Y<0
QUIT
SET AOULP(+Y)=""
+2 IF '$DATA(AOULP)&(X'="^ALL")
GOTO END
+3 IF X="^ALL"
FOR AOU=0:0
SET AOU=$ORDER(^PSI(58.1,AOU))
if 'AOU
QUIT
SET AOULP(AOU)=""
EN2 if '$DATA(AOULP)
GOTO END
WRITE !!,"The right margin for this report is 80.",!,"You may queue the report to print at a later time.",!!
DEV KILL %ZIS,IOP
SET %ZIS="QM"
SET %ZIS("B")=""
DO ^%ZIS
IF POP
WRITE !,"NO DEVICE SELECTED OR REPORT PRINTED!"
GOTO END
+1 IF $DATA(IO("Q"))
KILL IO("Q")
SET ZTRTN="ENQ^PSGWODP"
SET ZTDESC="Print On-Demand Request"
if $DATA(AOULP)
SET ZTSAVE("AOULP(")=""
FOR G="BDT","EDT","SEL","IGDA"
if $DATA(@G)
SET ZTSAVE(G)=""
+2 IF $TEST
DO ^%ZTLOAD
DO HOME^%ZIS
KILL ZTSK
GOTO END
+3 USE IO
+4 ;
ENQ ;ENTRY POINT WHEN QUEUED
+1 ; Patch PSGW*2.3*19 are changes active
IF '$DATA(PSGWPFLG)
NEW PSGWPFLG
SET PSGWPFLG=0
IF $$GET^XPAR("ALL","PSGW_WS_LVL_ON")
SET PSGWPFLG=1
+2 KILL ^TMP("PSGWOD",$JOB)
SET AOU=0
AOU IF $DATA(AOULP)
SET AOU=$ORDER(AOULP(AOU))
IF 'AOU
DO PRINT^PSGWODPR
GOTO DONE
+1 IF '$DATA(AOULP)
SET AOU=$ORDER(^PSI(58.1,AOU))
IF 'AOU
DO PRINT^PSGWODPR
GOTO DONE
DRUG ;LOOP THROUGH DRUGS FOR AOU
+1 SET DRGDA=0
DRGLP SET DRGDA=$ORDER(^PSI(58.1,AOU,1,DRGDA))
if 'DRGDA
GOTO AOU
DO OD
GOTO DRGLP
+1 ;
OD ;ON DEMAND REQUESTS
+1 if '$ORDER(^PSI(58.1,AOU,1,DRGDA,5,0))
QUIT
SET ODA=0
ODLP SET ODA=$ORDER(^PSI(58.1,AOU,1,DRGDA,5,ODA))
if 'ODA
QUIT
SET LOC=^(ODA,0)
SET ODT=$PIECE(LOC,"^")
IF (ODT<BDT)!(ODT>EDT)
GOTO ODLP
+1 SET QD=$PIECE(LOC,"^",2)
SET EDUZ=$SELECT($PIECE(LOC,"^",3)'="":$PIECE(LOC,"^",3),1:"NOT LISTED")
SET DRGNM=$PIECE(^PSI(58.1,AOU,1,DRGDA,0),"^")
SET STAN=$SELECT($PIECE(^(0),"^",3)="":0,$PIECE(^(0),"^",3)>DT:0,1:1)
+2 SET LEDUZ=$SELECT(+$PIECE(LOC,"^",5):$PIECE(LOC,"^",5),1:"N/A")
SET LEDT=$SELECT(+$PIECE(LOC,"^",6):$PIECE(LOC,"^",6),1:"N/A")
DO BACKORD
+3 IF '$ORDER(^PSDRUG(DRGNM,0))
SET DIK="^PSI(58.1,"_AOU_",1,"
SET DA=DRGDA
SET DA(1)=AOU
DO ^DIK
KILL DIK
GOTO ODLP
+4 IF PSGWPFLG
Begin DoDot:1
+5 NEW IEN
SET DRGNAME=$$GET1^DIQ(50,DRGNM,.01)
SET IEN=DRGDA_","_AOU_","
+6 SET ^TMP("PSGWOD",$JOB,"ARCHSTOCK",$PIECE(ODT,"."),AOU,EDUZ,ODT,DRGNAME)=$$GET1^DIQ(58.11,IEN,1)
End DoDot:1
+7 SET DRGNAME=$PIECE(^PSDRUG(DRGNM,0),"^")
SET ^TMP("PSGWOD",$JOB,$PIECE(ODT,"."),AOU,EDUZ,ODT,DRGNAME)=QD_"^"_STAN_"^"_DRGDA_"^"_BOTOT_"^"_LEDUZ_"^"_LEDT
GOTO ODLP
DONE IF $EXTRACT(IOST)'="C"
WRITE @IOF
+1 IF $EXTRACT(IOST)="C"
if 'QFLG
DO SS^PSGWUTL1
END KILL EDITDT,PREV,ZTSK,^TMP("PSGWOD",$JOB),AOULP,JJ,ANS,AOU,BDT,DRGDA,DRGNAME,DRGNM,EDT,EDUZ,J,LEDT,LEDUZ,LOC,ODA,ODT,PGCT,QD,STAN,PSGDA,ADT,CAT,PSGWDT,PSGWODT,PSGWAOU,AMISFL,KEY,ODTM,TMDT,%,%I,%H,DA,G,D,DIE
+1 KILL %DT,%W,C,SEL,IGDA,D0,D1,D2,DI,DIC,DIYS,DLAYGO,DQ,IO("Q"),PSGWV,BOTOT,X,Y,BO,QFLG,PSGWDUZ,PRTFLG,PSGWDT,PSGWCAT,BON,ALL,BCFLG,NEWI,PSGDR,PSGWADT,PSGWD,PSGWDN,PSGWPFLG
DO ^%ZISC
+2 if $DATA(ZTQUEUED)
SET ZTREQ="@"
QUIT
BACKORD ;TOTAL ANY BACKORDERS
+1 SET X=DRGNM
SET BOTOT=0
SET DIC="^PSI(58.3,"
SET DIC(0)=""
DO ^DIC
if Y<0
QUIT
SET BO=+Y
FOR J=0:0
SET J=$SELECT($DATA(^PSI(58.3,BO,1,AOU,1,J)):$ORDER(^(J)),1:"")
if 'J
QUIT
if $SELECT($PIECE(^(J,0),"^",5)=""
SET BOTOT=BOTOT+$PIECE(^(0),"^",2)
+2 QUIT