VistA-WorldVistAEHR/r/OUTPATIENT_PHARMACY-PSO-APS.../PSOSUDP1.m

56 lines
5.1 KiB
Mathematica
Raw Permalink Normal View History

2009-11-29 13:37:14 -05:00
PSOSUDP1 ;BIR/RTR-Delete a batch of printed Rx's ; 1/10/96
;;7.0;OUTPATIENT PHARMACY;;DEC 1997
K PDIVFLAG I PSODIVS>1 K DIR W ! S DIR(0)="Y",DIR("B")="Y",DIR("A")="Delete batches from your division ("_$P($G(^PS(59,+$G(PSOSITE),0)),"^")_") only" D ^DIR K DIR S:Y=0 PDIVFLAG=1 I Y["^"!($D(DTOUT))!($D(DUOUT)) W !!?3,"Nothing deleted!" G END
W !!,"Enter a date range to see all batches printed from suspense within those dates."
BEG K ^TMP($J,"PSODES"),^TMP($J,"PSODESPR"),^UTILITY($J,"PSODEPT"),PSOOUT,DTOUT,PSOLISTD
W ! K %DT S %DT="AEX",%DT("A")="START DATE: " D ^%DT K %DT G:Y<0!($D(DTOUT)) ENDM S (%DT(0),BEGDATE)=Y W ! S %DT="AEX",%DT("A")="END DATE: " D ^%DT K %DT G:Y<0!($D(DTOUT)) ENDM S ENDDATE=Y
S BEGDATE=BEGDATE-.0001,ENDDATE=ENDDATE+.9999,RECNT=1 W !!,"Gathering batches, please wait...",! H 1
F ZZZ=BEGDATE:0 S ZZZ=$O(^PS(52.5,"AS",ZZZ)) Q:'ZZZ!(ZZZ>ENDDATE) F XXX=0:0 S XXX=$O(^PS(52.5,"AS",ZZZ,XXX)) Q:'XXX F MMM=0:0 S MMM=$O(^PS(52.5,"AS",ZZZ,XXX,MMM)) Q:'MMM D
.I '$G(PDIVFLAG),MMM=$G(PSOSITE) S ^TMP($J,"PSODES",RECNT,ZZZ,XXX,MMM)="",RECNT=RECNT+1
.I $G(PDIVFLAG) S ^TMP($J,"PSODES",RECNT,ZZZ,XXX,MMM)="",RECNT=RECNT+1
I '$D(^TMP($J,"PSODES")) W $C(7),!!,"There are no printed batches found for that date range!",! G BEG
H 1 W @IOF W !,"BATCH",?8,"QUEUED TO PRINT ON:",?30,"PRINTED BY:",?59,"DIVISION" W ! F AA=1:1:78 W "-"
W ! F AAA=0:0 S AAA=$O(^TMP($J,"PSODES",AAA)) Q:'AAA!($G(PSOOUT)) S PSIDATE=$O(^TMP($J,"PSODES",AAA,0)),PSODUZ=$O(^TMP($J,"PSODES",AAA,PSIDATE,0)),PSPDIV=$O(^TMP($J,"PSODES",AAA,PSIDATE,PSODUZ,0)) D
.S Y=PSIDATE X ^DD("DD") S PSODATE=Y,PSOUSER=$S($D(^VA(200,PSODUZ,0)):$E($P($G(^(0)),"^"),1,28),1:"UNKNOWN"),PSPRDIV=$E($P($G(^PS(59,PSPDIV,0)),"^"),1,20) D:($Y+5)>IOSL Q:$G(PSOOUT) W !?1,AAA,?8,PSODATE,?30,PSOUSER,?59,PSPRDIV
..W ! K DIR S DIR(0)="E" D ^DIR K DIR S:'Y PSOOUT=1 I Y W @IOF W !,"BATCH",?8,"QUEUED TO PRINT ON:",?30,"PRINTED BY:",?59,"DIVISION" W ! F AA=1:1:78 W "-"
I $G(PSOOUT),Y="" G END
S RECNT=RECNT-1,PSOOUT=0 W ! K DIR S DIR("A")="Select Batch(s) to delete",DIR(0)="L^1:"_RECNT D ^DIR K DIR G:Y["^"!($D(DTOUT))!($D(DUOUT)) ENDM
S COUNT=1 F ZZ=1:1:$L(Y) S ZZZ=$E(Y,ZZ) I ZZZ="," S COUNT=COUNT+1
S COUNT=COUNT-1 F JJ=1:1:COUNT S RR=$P(Y,",",JJ),^TMP($J,"PSODESPR",RR)=""
YLOOP I $G(Y(1)) F PSYLOOP=0:0 S PSYLOOP=$O(Y(PSYLOOP)) Q:'PSYLOOP D
.S COUNT=1 F ZZ=1:1:$L(Y(PSYLOOP)) S ZZZ=$E(Y(PSYLOOP),ZZ) I ZZZ="," S COUNT=COUNT+1
.S COUNT=COUNT-1 F JJ=1:1:COUNT S RR=$P(Y(PSYLOOP),",",JJ),^TMP($J,"PSODESPR",RR)=""
W !!,"Batches selected for Deletion are:",! F ZZZ=0:0 S ZZZ=$O(^TMP($J,"PSODESPR",ZZZ)) Q:'ZZZ D
.S PSIDATE=$O(^TMP($J,"PSODES",ZZZ,0)),PSODUZ=$O(^TMP($J,"PSODES",ZZZ,PSIDATE,0)) S Y=PSIDATE X ^DD("DD") S PSODATE=Y,PSOUSER=$S($D(^VA(200,PSODUZ,0)):$P($G(^(0)),"^"),1:"UNKNOWN")
.W !,"Batch ",ZZZ," Queued for ",PSODATE," by ",PSOUSER
W ! K DIR S DIR(0)="Y",DIR("B")="N",DIR("A")="Before Deleting, would you like a list of these prescriptions" D ^DIR K DIR G:Y["^"!($D(DTOUT)) ENDM
I Y W ! S PSOLISTD=1 S DIR(0)="SB^S:SCREEN;P:PRINTER",DIR("A")="Print list to the screen or to a printer",DIR("B")="Screen" D ^DIR K DIR I $D(DIRUT) G END
I $G(PSOLISTD),Y="P" D DEQUE^PSOSUBCH G ENDM
I $G(PSOLISTD) D LIST I $G(PSOOUT) G END
;I Y D LIST I $G(PSOOUT) G END
DEL W ! K DIR S DIR(0)="Y",DIR("B")="Y",DIR("A")="Are you sure you want to delete the batches" D ^DIR K DIR I Y'=1 G ENDM
F GG="PSOPAR","PSOSYS","PSOSITE" S:$D(@GG) ZTSAVE(GG)=""
F NNN=0:0 S NNN=$O(^TMP($J,"PSODESPR",NNN)) Q:'NNN D
.S PSRDATE=$O(^TMP($J,"PSODES",NNN,0)),PSRDUZ=$O(^TMP($J,"PSODES",NNN,PSRDATE,0)),PSRDIV=$O(^TMP($J,"PSODES",NNN,PSRDATE,PSRDUZ,0))
.S ^UTILITY($J,"PSODEPT",PSRDATE,PSRDUZ,PSRDIV)=""
S ZTSAVE("^UTILITY($J,""PSODEPT"",")=""
W ! S ZTRTN="BEG^PSOSUDP2",ZTDESC="DELETE PRINTED BATCHES FROM SUSPENSE",ZTIO="",ZTDTH=$H D ^%ZTLOAD
I $D(ZTSK) W !!,"PRINTED BATCHES QUEUED FOR DELETION!",!!
G END
ENDM W !!?3,"Nothing deleted!"
END K ^TMP($J,"PSODES"),^TMP($J,"PSODESPR"),^UTILITY($J,"PSODEPT"),%DT,%ZIS,AA,AAA,BEGDATE,COUNT,DUOUT,DTOUT,ENDDATE,GG,INRX,JJ,LLL,MMM,NNN,POP,PSIDATE,PSODATE,PSODUZ,PSOREDEV,PSORTIME,PSOUSER,PSPDIV,PDPRDIV,PDIVFLAG,PSYLOOP,PSOLISTD
K PSRDATE,PSRDIV,PSRDUZ,RECNT,REDT,REDUZ,RESITE,RR,SS,XXX,ZZ,ZZZ,ZZZ Q
LIST F LLL=0:0 S LLL=$O(^TMP($J,"PSODESPR",LLL)) Q:'LLL!($G(PSOOUT)) D
.W ! S DIR(0)="E" D ^DIR K DIR S:'Y PSOOUT=1 Q:$G(PSOOUT)
.D HEAD S REDT=$O(^TMP($J,"PSODES",LLL,0)),REDUZ=$O(^TMP($J,"PSODES",LLL,REDT,0)) S RESITE=$O(^TMP($J,"PSODES",LLL,REDT,REDUZ,0)) F SS=0:0 S SS=$O(^PS(52.5,"AS",REDT,REDUZ,RESITE,SS)) Q:'SS!($G(PSOOUT)) D
..F GG=0:0 S GG=$O(^PS(52.5,"AS",REDT,REDUZ,RESITE,SS,GG)) Q:'GG!($G(PSOOUT)) D:($Y+5)>IOSL HEADONE Q:$G(PSOOUT) I $D(^PS(52.5,GG,0)) S INRX=$P(^(0),"^") I $D(^PSRX(INRX,0)) D
...W !,$P(^PSRX(INRX,0),"^"),?20,$P($G(^DPT(+$P(^PSRX(INRX,0),"^",2),0)),"^"),?60,$S($P($G(^PS(52.5,GG,0)),"^",5):"(PARTIAL)",$P($G(^(0)),"^",12):"(REPRINT)",1:"")
I $G(PSOOUT),(Y="") Q
S PSOOUT=0 I Y'=0 W !,"END OF LIST"
Q
HEAD W @IOF W !,"RX #",?20,"PATIENT NAME",?60,"BATCH ",LLL,! F ZZZZ=1:1:78 W "-"
Q
HEADONE S DIR(0)="E" D ^DIR K DIR I 'Y S PSOOUT=1 Q
W @IOF W !,"RX #",?20,"PATIENT NAME",?60,"BATCH ",LLL,! F ZZZZ=1:1:78 W "-"
Q