Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: PSOSURST

PSOSURST.m

Go to the documentation of this file.
PSOSURST ;BIR/RTR-Reset and Reprint from Suspense ; 7/20/96
 ;;7.0;OUTPATIENT PHARMACY;**10,367**;DEC 1997;Build 62
 D:'$D(PSOPAR) ^PSOLSET I '$D(PSOPAR) G END
 N X S X="PSXRPPL1" X ^%ZOSF("TEST") K X G:'$T START
 G:$G(PSXSYS)&($D(^XUSEC("PSXCMOPMGR",DUZ)))&($D(^XUSEC("PSX XMIT",DUZ))) ^PSXRPPL1
START W !!,"Enter a date range to see all batches printed from suspense within those dates."
BEG K ^TMP($J,"PSORES"),^TMP($J,"PSORESPR"),^UTILITY($J,"PSOREPT"),PSOOUT,DTOUT,PSOLISTY
 W ! K %DT S %DT="AEX",%DT("A")="Start date: " D ^%DT K %DT G:Y<0!($D(DTOUT)) END S (%DT(0),BEGDATE)=Y W ! S %DT="AEX",%DT("A")="End date: " D ^%DT K %DT G:Y<0!($D(DTOUT)) END 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 MMM=$G(PSOSITE) S ^TMP($J,"PSORES",RECNT,ZZZ,XXX,MMM)="",RECNT=RECNT+1
 I '$D(^TMP($J,"PSORES")) W $C(7),!!,"There are no printed batches found for that date range!",! G BEG
 H 1 W @IOF W !?1,"BATCH",?10,"QUEUED TO PRINT ON:",?40,"PRINTED BY:",?56,$E($P($G(^PS(59,PSOSITE,0)),"^"),1,23),! F AA=1:1:78 W "-"
 W ! F AAA=0:0 S AAA=$O(^TMP($J,"PSORES",AAA)) Q:'AAA!($G(PSOOUT))  S PSIDATE=$O(^TMP($J,"PSORES",AAA,0)),PSODUZ=$O(^TMP($J,"PSORES",AAA,PSIDATE,0)) D
 .S Y=PSIDATE X ^DD("DD") S PSODATE=Y,PSOUSER=$S($D(^VA(200,PSODUZ,0)):$P($G(^(0)),"^"),1:"UNKNOWN") D:($Y+5)>IOSL  Q:$G(PSOOUT)  W !?2,AAA,?10,PSODATE,?40,PSOUSER
 ..W ! K DIR S DIR(0)="E" D ^DIR K DIR S:'Y PSOOUT=1 I Y W @IOF W !?1,"BATCH",?10,"QUEUED TO PRINT ON:",?40,"PRINTED BY:",?56,$E($P($G(^PS(59,PSOSITE,0)),"^"),1,23),! 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 reprint",DIR(0)="L^1:"_RECNT D ^DIR K DIR I Y["^"!($D(DTOUT))!($D(DUOUT)) W !!?3,"Nothing queued to print!",! G START
 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,"PSORESPR",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,"PSORESPR",RR)=""
 W !!,"Batches selected for Reprint are:",! F ZZZ=0:0 S ZZZ=$O(^TMP($J,"PSORESPR",ZZZ)) Q:'ZZZ  D
 .S PSIDATE=$O(^TMP($J,"PSORES",ZZZ,0)),PSODUZ=$O(^TMP($J,"PSORES",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
 ;
 I $$GET1^DIQ(59,PSOSITE,134)'="" D  I $D(DIRUT)!($D(DTOUT)) W !!?3,"Nothing queued to print!",! G START
 . W ! K DIR,DIRUT S DIR("A")="Reprint the FDA Medication Guide",DIR(0)="Y",DIR("B")="No"
 . D ^DIR K DIR I $D(DIRUT)!($D(DTOUT)) Q
 . S PSOMGREP=Y
 ;
 W ! K DIR S DIR(0)="Y",DIR("B")="N",DIR("A")="Before Reprinting, would you like a list of these prescriptions" D ^DIR K DIR I Y["^"!($D(DTOUT)) W !!?3,"Nothing queued to print!",! G START
 I Y W ! S PSOLISTY=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) W !!?3,"Nothing queued to print!",! G START
 I $G(PSOLISTY),Y="P" D ^PSOSUBCH G START
 I $G(PSOLISTY) D LIST I $G(PSOOUT) G START
QUE W ! K %DT D NOW^%DTC S %DT="REAX",%DT(0)=%,%DT("B")="NOW",%DT("A")="Queue labels to reprint at what time: " D ^%DT K %DT I $D(DTOUT)!(Y<0) W !!?3,"Nothing queued to print!",! G START
 S PSOSUREP=1,PSORTIME=Y
 W ! S %ZIS("A")="REPRINT LABEL DEVICE: ",%ZIS("B")="",%ZIS="MQN" D ^%ZIS I POP!($E(IOST)["C") W !!?3,"Nothing queued to print!",! G START
 N PSOIOS S PSOIOS=IOS D DEVBAR^PSOBMST
 S PSOBARS=PSOBAR1]""&(PSOBAR0]"")&$P(PSOPAR,"^",19)
 S PSOREDEV=ION
 ;
 ; Asking FDA Med Guide printer
 I $G(PSOMGREP),$$GET1^DIQ(59,PSOSITE,134)'="" N FDAPRT S FDAPRT="" D  I FDAPRT="^"!($G(PSOFDAPT)="") W !!?3,"Nothing queued to print!",! G START
 . F  D  Q:FDAPRT'=""
 . . S FDAPRT=$$SELPRT^PSOFDAUT($P($G(PSOFDAPT),"^"))
 . . I FDAPRT="" W $C(7),!,"You must select a valid FDA Medication Guide printer."
 . I FDAPRT'="",(FDAPRT'="^") S PSOFDAPT=FDAPRT
 ;
 S ZTRTN="BEG^PSOSUSRP",ZTDTH=PSORTIME,ZTIO=PSOREDEV,ZTDESC="REPRINT LABELS FROM SUSPENSE"
 F GG="PSOPAR","PSOSYS","PSOSITE","PSOSUREP","PSOMGREP","PSOBARS","PSOBAR0","PSOBAR1","PSOFDAPT" S:$D(@GG) ZTSAVE(GG)=""
 F NNN=0:0 S NNN=$O(^TMP($J,"PSORESPR",NNN)) Q:'NNN  D
 .S PSRDATE=$O(^TMP($J,"PSORES",NNN,0)),PSRDUZ=$O(^TMP($J,"PSORES",NNN,PSRDATE,0)),PSRDIV=$O(^TMP($J,"PSORES",NNN,PSRDATE,PSRDUZ,0))
 .S ^UTILITY($J,"PSOREPT",PSRDATE,PSRDUZ,PSRDIV)=""
 S ZTSAVE("^UTILITY($J,""PSOREPT"",")="" D ^%ZTLOAD
 W !!,"REPRINTED LABELS QUEUED TO PRINT!",!
END K ^TMP($J,"PSORES"),^TMP($J,"PSORESPR"),^UTILITY($J,"PSOREPT"),%DT,%ZIS,AA,AAA,BEGDATE,COUNT,DUOUT,DTOUT
 K ENDDATE,GG,INRX,JJ,LLL,MMM,NNN,POP,PSIDATE,PSODATE,PSODUZ,PSOREDEV,PSORTIME,PSOSUREP,PSOUSER,PSYLOOP,PSOMGREP
 K PSRDATE,PSRDIV,PSOLISTY,PSRDUZ,RECNT,REDT,REDUZ,RR,SS,XXX,ZZ,ZZZ,ZZZ D ^%ZISC Q
LIST F LLL=0:0 S LLL=$O(^TMP($J,"PSORESPR",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,"PSORES",LLL,0)),REDUZ=$O(^TMP($J,"PSORES",LLL,REDT,0)) F SS=0:0 S SS=$O(^PS(52.5,"AS",REDT,REDUZ,PSOSITE,SS)) Q:'SS!($G(PSOOUT))  D
 ..F GG=0:0 S GG=$O(^PS(52.5,"AS",REDT,REDUZ,PSOSITE,SS,GG)) Q:'GG!($G(PSOOUT))  D:($Y+5)>IOSL HEADONE Q:$G(PSOOUT)  I $D(^PS(52.5,GG,0)),$P($G(^(0)),"^",6)=PSOSITE 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
 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