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

PSDOPTN.m

Go to the documentation of this file.
  1. PSDOPTN ;BIR/LTL - Review OP Transactions for a Drug (cont.) ; 24 Jan 95
  1. ;;3.0;CONTROLLED SUBSTANCES ;**18,55,75,85**;13 Feb 97;Build 2
  1. ;
  1. ;References to ^PSD(58.8, covered by DBIA2711
  1. ;References to DD(58.81 and ^PSD(58.81 are covered by DBIA2808
  1. ;References to ^PSDRUG( are covered by DBIA221
  1. ;References to ^PSRX( are covered by DBIA986
  1. S DIR(0)="DA^2910501::AEPT"
  1. S DIR("A")="Beginning date@time filled (not posted): ",DIR("?")="I will list Outpatient transactions for your selected drug(s) within your selected date@time range. Please don't enter a date@time in the future" W ! D ^DIR G:Y<1 END
  1. S (PSDT,PSDTB)=Y,PSDTB(2)=Y(0)
  1. S DIR(0)="DA^"_PSDT_"::AET"
  1. S DIR("A")="Ending date@time filled (not posted): "
  1. S DIR("?")=$G(DIR("?"))_" or before "_$G(PSDTB(2))
  1. W ! D ^DIR K DIR G:Y<1 END S PSDTB(1)=Y,PSDTB(3)=Y(0)
  1. S:'$P(PSDTB(1),".",2) PSDTB(1)=PSDTB(1)+.999999
  1. S Y=$P($G(^PSD(58.8,+PSDLOC,2)),"^",9),C=$P(^DD(58.8,24,0),"^",2) D Y^DIQ S PSDEV=Y
  1. DEV ;device
  1. K IO("Q") N %ZIS,IOP,POP S %ZIS="Q",%ZIS("B")=PSDEV W ! D ^%ZIS I POP W !,"NO DEVICE SELECTED OR OUTPUT PRINTED!" Q
  1. I $D(IO("Q")) N ZTDESC,ZTIO,ZTRTN,ZTSAVE,ZTDTH,ZTSK S ZTRTN="START^PSDOPTN",ZTDESC="Drug OP transaction review" D SAVE D ^%ZTLOAD,HOME^%ZIS S PSDOUT=1 G END
  1. START ;compiles
  1. U IO N PSDR,PG S (PG,PSDOUT)=0 K LN D HEADER S PSDT=PSDT-1
  1. ;loop thru Prescription file by date filled
  1. F S PSDT=$O(^PSRX("AD",PSDT)) Q:'PSDT!(PSDT>PSDTB(1)) W:$E(IOST)="C" "." S PSDT(1)=0 D
  1. .F S PSDT(1)=$O(^PSRX("AD",PSDT,PSDT(1))) Q:'PSDT(1) D
  1. ..S PSDT(5)=$G(^PSRX(PSDT(1),0))
  1. ..S PSDT(2)=$P($G(^PSDRUG(+$P(PSDT(5),U,6),0)),U) Q:PSDT(2)']""
  1. ..Q:'$D(^TMP("PSD",$J,PSDT(2))) S PSDT(4)=""
  1. ..F S PSDT(4)=$O(^PSRX("AD",PSDT,PSDT(1),PSDT(4))) Q:PSDT(4)="" D
  1. ...S PSDCMOP=0
  1. ...I $D(^PSRX(PSDT(1),4)) S PSDCMP=0 F S PSDCMP=$O(^PSRX(PSDT(1),4,PSDCMP)) Q:'PSDCMP D
  1. ....I +$P(^PSRX(PSDT(1),4,PSDCMP,0),U,3)=+PSDT(4),$P(^PSRX(PSDT(1),4,PSDCMP,0),U,4)<3 S PSDCMOP=1
  1. ...;Returned to stock?
  1. ...Q:$S('PSDT(4):$P($G(^PSRX(PSDT(1),2)),U,15),1:$P($G(^PSRX(PSDT(1),1,PSDT(4),0)),U,16))
  1. ...;posted to the vault?
  1. ...S PSDT(3)=0
  1. ...F S PSDT(3)=$O(^PSD(58.81,"AOP",PSDT(1),PSDT(3))) Q:'PSDT(3)!($S('PSDT(4)&('$P($G(^PSD(58.81,+PSDT(3),6)),U,2)):1,PSDT(4)=$P($G(^(6)),U,2):1,1:0))
  1. ...Q:PSDT(3)
  1. ...;suspended & printed
  1. ...S (PSDT(3),PSDT(8))=0
  1. ...I PSDT>DT D Q:'PSDT(8)
  1. ....F S PSDT(3)=$O(^PSRX(PSDT(1),"L",PSDT(3))) Q:'PSDT(3) S:$P($G(^PSRX(PSDT(1),"L",PSDT(3),0)),U,2)=PSDT(4) PSDT(8)=1
  1. ...;quantity
  1. ...S PSDT(6)=$S('PSDT(4):$P(PSDT(5),U,7),1:$P($G(^PSRX(PSDT(1),1,PSDT(4),0)),U,4))
  1. ...S DFN=$P(PSDT(5),U,2) N C S Y=DFN,C=$P(^DD(58.81,73,0),U,2) D Y^DIQ
  1. ...S PSDT(7)=Y D PID^VADPT6 S PSDT(7)=PSDT(7)_" ("_VA("BID")_")"
  1. ...I $G(PSDCMOP) S PSDCMOP=0 Q
  1. ...S:$P(PSDT(5),U)]"" ^TMP("PSDO",$J,PSDT(2),$P(PSDT(5),U),PSDT(4))=PSDT(6)_U_PSDT_U_PSDT(7)
  1. K PSDCMP
  1. I '$D(^TMP("PSDO",$J)) W !!,"Nothing to Report.",!! G END
  1. F S PSDT=$O(^TMP("PSDO",$J,PSDT)) Q:PSDT']""!PSDOUT D Q:PSDOUT
  1. .D:$Y+5>IOSL HEADER Q:PSDOUT W !!,"Drug => ",PSDT S PSDT(1)=0
  1. .F S PSDT(1)=$O(^TMP("PSDO",$J,PSDT,PSDT(1))) Q:'PSDT(1)!PSDOUT D Q:PSDOUT
  1. ..S PSDT(2)=""
  1. ..F S PSDT(2)=$O(^TMP("PSDO",$J,PSDT,PSDT(1),PSDT(2))) Q:PSDT(2)=""!PSDOUT D Q:PSDOUT
  1. ...I $Y+4>IOSL D HEADER Q:PSDOUT W !!,PSDT," (continued)"
  1. ...W !!,PSDT(1)," (",PSDT(2),")"
  1. ...S PSDT(3)=$G(^TMP("PSDO",$J,PSDT,PSDT(1),PSDT(2)))
  1. ...W ?9,$J($P(PSDT(3),U),4) S Y=$P(PSDT(3),U,2) X ^DD("DD") W ?20,Y
  1. ...W ?40,$P(PSDT(3),U,3)
  1. END W:$E(IOST)'="C" @IOF
  1. I $E(IOST)="C",'PSDOUT S DIR(0)="EA",DIR("A")="END OF REPORT! Press <RET> to return to the menu." W ! D ^DIR
  1. D ^%ZISC S:$D(ZTQUEUED) ZTREQ="@"
  1. D KVAR^VADPT K IO("Q"),VA("PID"),VA("BID"),^TMP("PSDO",$J),PSDCMOP
  1. Q
  1. I $$S^%ZTLOAD W !!,"Task #",$G(ZTSK),", ",$G(ZTDESC)," was stopped by ",$P($G(^VA(200,+$G(DUZ),0)),U),"." S PSDOUT=1
  1. W:$Y @IOF S $P(LN,"-",81)="",PG=PG+1 W !,"Outpatient Activity from ",PSDTB(2)," to ",PSDTB(3),?70,"PAGE: ",PG,!,LN,!,"Rx#",?10,"QTY",?20,"Fill Date",?40,"Patient",!,LN
  1. Q
  1. SAVE ;
  1. S ZTSAVE("^TMP(""PSD"",$J,")=""
  1. S (ZTSAVE("PSDT"),ZTSAVE("PSDLOC"),ZTSAVE("PSDTB"),ZTSAVE("PSDTB("))=""
  1. Q