source: WorldVistAEHR/trunk/r/CONTROLLED_SUBSTANCES-PSD/PSDPSI.m@ 1608

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

initial load of WorldVistAEHR

File size: 4.5 KB
RevLine 
[613]1PSDPSI ;BIR/JPW-Green Sheets Placed on Insp Hold Rpt ; 29 Aug 94
2 ;;3.0; CONTROLLED SUBSTANCES ;;13 Feb 97
3 I '$D(PSDSITE) D ^PSDSET Q:'$D(PSDSITE)
4ASKD ;ask disp location
5 S PSDS=$P(PSDSITE,U,3),PSDSN=$P(PSDSITE,U,4)
6 I $P(PSDSITE,U,5) S PSDS=PSDS_"^"_+$P(^PSD(58.8,+PSDS,0),"^",5) G ASKN
7 K DIC,DA S DIC=58.8,DIC(0)="QEAZ",DIC("S")="I $P(^(0),""^"",3)=+PSDSITE,$S($P(^(0),""^"",2)[""M"":1,$P(^(0),""^"",2)[""S"":1,1:0)"
8 S DIC("A")="Select Primary Dispensing Site: ",DIC("B")=$P(PSDSITE,U,4)
9 D ^DIC K DIC G:Y<0 END
10 S PSDS=+Y,PSDSN=$P(Y,"^",2),PSDS=PSDS_"^"_+$P(Y(0),"^",5)
11 S $P(PSDSITE,U,3)=+Y,$P(PSDSITE,U,4)=PSDSN
12ASKN ;ask naou or group
13 W !!,?5,"Select one of the following:",!!,?10,"N",?20,"NAOU (One, Some, or ^ALL)",!,?10,"G",?20,"Group of NAOUs",!
14 K DA,DIR,DIRUT S DIR(0)="SOA^N:NAOU;G:Group of NAOUs",DIR("A")="Select Method: "
15 S DIR("?",1)="Enter 'N' to select one, some, or ^ALL for all NAOU(s).",DIR("?")="Enter 'G' to select a group of NAOUs, or '^' to quit"
16 D ^DIR K DIR G:$D(DIRUT) END S SEL=Y D NOW^%DTC S PSDT=X,PSDPT=+$E(%,1,12) K DA,DIC S CNT=0
17 I SEL="G" D GROUP G:'$D(PSDG) END G DEV
18 F S DIC=58.8,DIC("A")="Select NAOU: ",DIC(0)="QEA",DIC("S")="I $P(^(0),""^"",2)=""N"",'$P(^(0),""^"",7),$P(^(0),""^"",4)=+PSDS" D ^DIC K DIC Q:Y<0 D
19 .S NAOU(+Y)="",CNT=CNT+1
20 I '$D(NAOU)&(X'="^ALL") G END
21 S:X="^ALL" ALL=1
22DEV ;ask device and queue info
23 W !!,"You may queue this report to print at a later time.",!!
24 S Y=$P($G(^PSD(58.8,+PSDS,2)),"^",9),C=$P(^DD(58.8,24,0),"^",2) D Y^DIQ S PSDEV=Y
25 K %ZIS,IOP,IO("Q"),POP S %ZIS="QM",%ZIS("B")=PSDEV D ^%ZIS I POP W !,"NO DEVICE SELECTED OR REPORT PRINTED!" G END
26 I $D(IO("Q")) K IO("Q"),ZTIO,ZTSAVE,ZTDTH,ZTSK S ZTRTN="START^PSDPSI",ZTDESC="CS Green Sheets Placed on Insp Hold" D SAVE,^%ZTLOAD,HOME^%ZIS K ZTSK G END
27 U IO
28START ;compile data
29 K ^TMP("PSDPSI",$J)
30 I $D(PSDG) F PSD=0:0 S PSD=$O(PSDG(PSD)) Q:'PSD F PSDN=0:0 S PSDN=$O(^PSI(58.2,PSD,3,PSDN)) Q:'PSDN I $D(^PSD(58.8,PSDN,0)),'$P(^(0),"^",7),$P(^(0),"^",4)=+PSDS S NAOU(PSDN)="",CNT=CNT+1
31 I $D(ALL) F PSD=0:0 S PSD=$O(^PSD(58.8,PSD)) Q:'PSD I $D(^PSD(58.8,PSD,0)),$P(^(0),"^",2)="N",$P(^(0),"^",4)=+PSDS,'$P(^(0),"^",7) S NAOU(+PSD)=""
32 F PSD=0:0 S PSD=$O(NAOU(PSD)) Q:'PSD F PSDA=0:0 S PSDA=$O(^PSD(58.81,"AD",11,PSD,PSDA)) Q:'PSDA I $D(^PSD(58.81,PSDA,0)) S NODE=^PSD(58.81,PSDA,0) D
33 .S PSDNA=$S($P($G(^PSD(58.8,+PSD,0)),"^")]"":$P(^(0),"^"),1:"ZZ/"_PSD)
34 .S DRUG=+$P(NODE,"^",5),DRUGN=$S($P($G(^PSDRUG(DRUG,0)),"^")]"":$P(^(0),"^"),1:"ZZ/"_DRUG)
35 .S PSDBY=+$P(NODE,"^",7),PSDBY=$P($G(^VA(200,+PSDBY,0)),"^")
36 .S (PSDTH,Y)=+$P($G(^PSD(58.81,PSDA,1.5)),"^",3) X ^DD("DD") S PSDTH=Y
37 .S PSDANS=$G(^PSD(58.81,PSDA,1.6))
38 .S NUM=$P(NODE,"^",17),^TMP("PSDPSI",$J,PSDNA,NUM,DRUGN)=PSDBY_"^"_PSDTH_"^"_PSDANS
39PRINT ;print green sheets picked up naou, green sheet #
40 S (PG,PSDOUT,NAOU)=0 D NOW^%DTC S Y=+$E(%,1,12) X ^DD("DD") S RPDT=Y
41 K LN S $P(LN,"-",80)="" I '$D(^TMP("PSDPSI",$J)) D HDR W !!,?10,"**** NO GREEN SHEETS ON INSPECTOR HOLD ****" G END
42 S NAOU="" F S NAOU=$O(^TMP("PSDPSI",$J,NAOU)) Q:NAOU=""!(PSDOUT) D HDR Q:PSDOUT W !,?2,"=> NAOU: "_NAOU,! D Q:PSDOUT
43 .S NUM="" F S NUM=$O(^TMP("PSDPSI",$J,NAOU,NUM)) Q:NUM=""!(PSDOUT) D:$Y+6>IOSL HDR Q:PSDOUT S DRUG=$O(^TMP("PSDPSI",$J,NAOU,NUM,0)) Q:DRUG="" D
44 ..W !,NUM,?12,DRUG,?55,$P(^TMP("PSDPSI",$J,NAOU,NUM,DRUG),"^"),!,?15,$P(^TMP("PSDPSI",$J,NAOU,NUM,DRUG),"^",2),!
45 ..W:$P(^TMP("PSDPSI",$J,NAOU,NUM,DRUG),"^",3)]"" ?15,$P(^TMP("PSDPSI",$J,NAOU,NUM,DRUG),"^",3),!
46DONE I $E(IOST)'="C" W @IOF
47 I $E(IOST,1,2)="C-",'PSDOUT W ! K DIR,DIRUT S DIR(0)="EA",DIR("A")="END OF REPORT! Press <RET> to return to the menu" D ^DIR K DIR
48END K %,%H,%I,%ZIS,ALL,C,CNT,DA,DIC,DIR,DIROUT,DIRUT,DRUG,DRUGN,DTOUT,DUOUT,LN,NAOU,NODE,NUM
49 K OK,PG,POP,PSD,PSDBY,PSDA,PSDANS,PSDEV,PSDG,PSDN,PSDNA,PSDS,PSDSN,PSDOUT,PSDPT,PSDT,PSDTH,RPDT,SEL,X,Y,ZTDESC,ZTDTH,ZTRTN,ZTSAVE,ZTSK
50 K ^TMP("PSDPSI",$J) D ^%ZISC
51 S:$D(ZTQUEUED) ZTREQ="@"
52 Q
53GROUP ;select group of naous
54 K DA,DIC F S DIC=58.2,DIC("A")="Select NAOU INVENTORY GROUP NAME: ",DIC(0)="QEA",DIC("S")="I $S($D(^PSI(58.2,""CS"",+Y)):1,1:0)" D ^DIC K DIC Q:Y<0 S PSDG(+Y)=""
55 Q
56SAVE S (ZTSAVE("PSDT"),ZTSAVE("CNT"),ZTSAVE("PSDS"))="" S:$D(PSDG) ZTSAVE("PSDG(")="" S:$D(NAOU) ZTSAVE("NAOU(")="" S:$D(ALL) ZTSAVE("ALL")=""
57 Q
58HDR ;header for log
59 I $E(IOST,1,2)="C-",PG W ! K DA,DIR S DIR(0)="E" D ^DIR K DIR I 'Y S PSDOUT=1 Q
60 S PG=PG+1 W:$Y @IOF W !,?15,"Green Sheets Placed on Hold for Inspector Review",?70,"Page: ",PG,!,?26,"Run Date: ",RPDT,!
61 W !,"DISP #",?12,"DRUG",?55,"PLACED ON HOLD BY",!,?15,"DATE PLACED ON HOLD",!,?15,"HOLD REMARKS"
62 W !,LN,!
63 Q
Note: See TracBrowser for help on using the repository browser.