source: WorldVistAEHR/trunk/r/CONTROLLED_SUBSTANCES-PSD/PSDOPTN.m@ 1604

Last change on this file since 1604 was 613, checked in by George Lilly, 15 years ago

initial load of WorldVistAEHR

File size: 3.8 KB
Line 
1PSDOPTN ;BIR/LTL - Review OP Transactions for a Drug (cont.) ; 24 Jan 95
2 ;;3.0; CONTROLLED SUBSTANCES ;**18,55**;13 Feb 97
3 ;
4 ;References to ^PSD(58.8, covered by DBIA2711
5 ;References to DD(58.81 and ^PSD(58.81 are covered by DBIA2808
6 ;References to ^PSDRUG( are covered by DBIA221
7 ;References to ^PSRX( are covered by DBIA986
8 S DIR(0)="DA^2910501::AEPT"
9 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
10 S (PSDT,PSDTB)=Y,PSDTB(2)=Y(0)
11 S DIR(0)="DA^"_PSDT_"::AET"
12 S DIR("A")="Ending date@time filled (not posted): "
13 S DIR("?")=$G(DIR("?"))_" or before "_$G(PSDTB(2))
14 W ! D ^DIR K DIR G:Y<1 END S PSDTB(1)=Y,PSDTB(3)=Y(0)
15 S:'$P(PSDTB(1),".",2) PSDTB(1)=PSDTB(1)+.999999
16 S Y=$P($G(^PSD(58.8,+PSDLOC,2)),"^",9),C=$P(^DD(58.8,24,0),"^",2) D Y^DIQ S PSDEV=Y
17DEV ;device
18 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
19 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
20START ;compiles
21 U IO N PSDR,PG S (PG,PSDOUT)=0 K LN D HEADER S PSDT=PSDT-1
22 ;loop thru Prescription file by date filled
23 F S PSDT=$O(^PSRX("AD",PSDT)) Q:'PSDT!(PSDT>PSDTB(1)) W:$E(IOST)="C" "." S PSDT(1)=0 D
24 .F S PSDT(1)=$O(^PSRX("AD",PSDT,PSDT(1))) Q:'PSDT(1) D
25 ..S PSDT(5)=$G(^PSRX(PSDT(1),0))
26 ..S PSDT(2)=$P($G(^PSDRUG(+$P(PSDT(5),U,6),0)),U) Q:PSDT(2)']""
27 ..Q:'$D(^TMP("PSD",$J,PSDT(2))) S PSDT(4)=""
28 ..F S PSDT(4)=$O(^PSRX("AD",PSDT,PSDT(1),PSDT(4))) Q:PSDT(4)="" D
29 ...;Returned to stock?
30 ...Q:$S('PSDT(4):$P($G(^PSRX(PSDT(1),2)),U,15),1:$P($G(^PSRX(PSDT(1),1,PSDT(4),0)),U,16))
31 ...;posted to the vault?
32 ...S PSDT(3)=0
33 ...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))
34 ...Q:PSDT(3)
35 ...;suspended & printed
36 ...S (PSDT(3),PSDT(8))=0
37 ...I PSDT>DT D Q:'PSDT(8)
38 ....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
39 ...;quantity
40 ...S PSDT(6)=$S('PSDT(4):$P(PSDT(5),U,7),1:$P($G(^PSRX(PSDT(1),1,PSDT(4),0)),U,4))
41 ...S DFN=$P(PSDT(5),U,2) N C S Y=DFN,C=$P(^DD(58.81,73,0),U,2) D Y^DIQ
42 ...S PSDT(7)=Y D PID^VADPT6 S PSDT(7)=PSDT(7)_" ("_VA("BID")_")"
43 ...S:$P(PSDT(5),U)]"" ^TMP("PSDO",$J,PSDT(2),$P(PSDT(5),U),PSDT(4))=PSDT(6)_U_PSDT_U_PSDT(7)
44 I '$D(^TMP("PSDO",$J)) W !!,"Nothing to Report.",!! G END
45 F S PSDT=$O(^TMP("PSDO",$J,PSDT)) Q:PSDT']""!PSDOUT D Q:PSDOUT
46 .D:$Y+5>IOSL HEADER Q:PSDOUT W !!,"Drug => ",PSDT S PSDT(1)=0
47 .F S PSDT(1)=$O(^TMP("PSDO",$J,PSDT,PSDT(1))) Q:'PSDT(1)!PSDOUT D Q:PSDOUT
48 ..S PSDT(2)=""
49 ..F S PSDT(2)=$O(^TMP("PSDO",$J,PSDT,PSDT(1),PSDT(2))) Q:PSDT(2)=""!PSDOUT D Q:PSDOUT
50 ...I $Y+4>IOSL D HEADER Q:PSDOUT W !!,PSDT," (continued)"
51 ...W !!,PSDT(1)," (",PSDT(2),")"
52 ...S PSDT(3)=$G(^TMP("PSDO",$J,PSDT,PSDT(1),PSDT(2)))
53 ...W ?9,$J($P(PSDT(3),U),4) S Y=$P(PSDT(3),U,2) X ^DD("DD") W ?20,Y
54 ...W ?40,$P(PSDT(3),U,3)
55END W:$E(IOST)'="C" @IOF
56 I $E(IOST)="C",'PSDOUT S DIR(0)="EA",DIR("A")="END OF REPORT! Press <RET> to return to the menu." W ! D ^DIR
57 D ^%ZISC S:$D(ZTQUEUED) ZTREQ="@"
58 D KVAR^VADPT K IO("Q"),VA("PID"),VA("BID"),^TMP("PSDO",$J)
59 Q
60HEADER I $E(IOST,1,2)'="P-",PG S DIR(0)="E" D ^DIR K DIR I 'Y S PSDOUT=1 Q
61 I $$S^%ZTLOAD W !!,"Task #",$G(ZTSK),", ",$G(ZTDESC)," was stopped by ",$P($G(^VA(200,+$G(DUZ),0)),U),"." S PSDOUT=1
62 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
63 Q
64SAVE ;
65 S ZTSAVE("^TMP(""PSD"",$J,")=""
66 S (ZTSAVE("PSDT"),ZTSAVE("PSDLOC"),ZTSAVE("PSDTB"),ZTSAVE("PSDTB("))=""
67 Q
Note: See TracBrowser for help on using the repository browser.