source: FOIAVistA/trunk/r/CONTROLLED_SUBSTANCES-PSD/PSDPLOG1.m@ 1783

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

initial load of FOIAVistA 6/30/08 version

File size: 4.9 KB
Line 
1PSDPLOG1 ;BIR/JPW,LTL-CS Inspector's Log (cont'd) ; 31 May 95
2 ;;3.0; CONTROLLED SUBSTANCES ;**22,28**;13 Feb 97
3 ;
4 ;References to ^PSD(58.8, covered by DBIA2711
5 ;References to ^PSD(58.81 are covered by DBIA2808
6 ;References to ^PSDRUG( are covered by DBIA221
7 ;References to ^PSI(58.16 are covered by DBIA213
8 ;References to ^PSI(58.2( are covered by DBIA213
9 ;
10START ;compile data
11 K ^TMP("PSDLOG",$J) S (PSDCNT,PSDOUT)=0
12 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),"^",3)=+PSDSITE S NAOU(PSDN)="",CNT=CNT+1
13 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),"^",3)=+PSDSITE,'$P(^(0),"^",7) S NAOU(+PSD)=""
14 F STAT=2.99:0 S STAT=$O(^PSD(58.8,"AC",STAT)) Q:('STAT)!(STAT>5) F PSD=0:0 S PSD=$O(^PSD(58.8,"AC",STAT,PSD)) Q:'PSD D LOOP
15 S STAT=10 F PSD=0:0 S PSD=$O(^PSD(58.8,"AC",STAT,PSD)) Q:'PSD D LOOP
16 ;PSD*3*28 22JUN00 (DAVE BLOCKER) ;perpetual Inventory
17 S STAT=13 F PSD=0:0 S PSD=$O(^PSD(58.8,"AC",STAT,PSD)) Q:'PSD I $P($G(^PSD(58.8,+PSD,2)),"^",5)'="" D LOOP
18 I $G(PSDRET) F PSDN=PSDSD:0 S PSDN=$O(^PSD(58.81,"ACT",PSDN)) Q:'PSDN!(PSDOUT) F JJ=0:0 S JJ=$O(^PSD(58.81,"ACT",PSDN,JJ)) Q:'JJ!(PSDOUT) D
19 .F PSDR=0:0 S PSDR=$O(^PSD(58.81,"ACT",PSDN,JJ,PSDR)) Q:'PSDR!(PSDOUT) F PSDA=0:0 S PSDA=$O(^PSD(58.81,"ACT",PSDN,JJ,PSDR,3,PSDA)) Q:'PSDA!(PSDOUT) S PSDOK="#" D
20 ..Q:'$D(^PSD(58.81,+PSDA,0)) S NODE=^PSD(58.81,PSDA,0),NODE3=$G(^(3))
21 ..S PSDRN=$S($P($G(^PSDRUG(+PSDR,0)),"^")]"":$P(^(0),"^"),1:"ZZ"_PSDR)
22 ..S PSD=+$P(NODE,"^",18) Q:'$D(NAOU(PSD))
23 ..S PSDNA=$S($P($G(^PSD(58.8,+PSD,0)),"^")]"":$P(^(0),"^"),1:"ZZ/"_PSD)
24 ..S NUM=$S($P(NODE,"^",17)]"":$P(NODE,"^",17),1:"UNKNOWN"),QTY=+$P(NODE3,"^",2),EXP=$P(NODE,"^",15),EXPD="" I EXP S Y=EXP X ^DD("DD") S EXPD=Y
25 ..S Y=$E(PSDN,1,7) X ^DD("DD") S PSDDT=Y
26 ..D SET
27 G:$D(ZTQUEUED) PRTQUE
28 I ASKN G PRINT^PSDPLOG3 Q
29 G PRINT^PSDPLOG2
30 Q
31PRTQUE ;queues print after compile
32 K ZTSAVE,ZTIO S ZTIO=PSDIO,ZTRTN=$S(ASKN:"PRINT^PSDPLOG3",1:"PRINT^PSDPLOG2"),ZTDESC="Print Narcotic Inspector Log",ZTDTH=$H
33 S (ZTSAVE("^TMP(""PSDLOG"",$J,"),ZTSAVE("CNT"),ZTSAVE("ASK"),ZTSAVE("ASKN"))=""
34 D ^%ZTLOAD K ^TMP("PSDLOG",$J),ZTSK
35END K %,%DT,%H,%I,%ZIS,ALL,ASK,ASKN,CNT,DA,DIC,DIE,DIR,DIROUT,DIRUT,DR,DTOUT,DUOUT,EXP,EXPD,JJ,NAOU,NODE,NODE3,NUM
36 K OK,PSD,PSDA,PSDCNT,PSDDT,PSDG,PSDIO,PSDOK,PSDOUT,PSDN,PSDNA,PSDPT,PSDR,PSDRN,PSDRD,PSDRDT,PSDRET,PSDSD,PSDST,PSDT,PSDTR
37 K QTY,SEL,STAT,STATN,TYP,TYPN,X,Y,ZTDESC,ZTDTH,ZTIO,ZTRTN,ZTSAVE,ZTSK
38 K ^TMP("PSDLOG",$J) D ^%ZISC
39 S:$D(ZTQUEUED) ZTREQ="@"
40 Q
41LOOP ;starts drug loop
42 F PSDR=0:0 S PSDR=$O(^PSD(58.8,"AC",STAT,PSD,PSDR)) Q:'PSDR D
43 .F PSDA=0:0 S PSDA=$O(^PSD(58.8,"AC",STAT,PSD,PSDR,PSDA)) Q:'PSDA I $D(^PSD(58.8,PSD,1,PSDR,3,PSDA,0)) S NODE=^PSD(58.8,PSD,1,PSDR,3,PSDA,0) D
44 ..;DAVE B (PSD*3*22) Check for matching ORDER STATUSs
45 ..;First check 58.8's order node for status inconsistency
46 ..S STAT1=$P(NODE,"^",11),STAT2=$P(NODE,"^",12)
47 ..I ($G(STAT1)=6)!($G(STAT1)=7)!($G(STAT1)=8)!($G(STAT1)=9)!($G(STAT1)=11)!($G(STAT1)=12) Q
48 ..I $G(STAT2)>0 Q
49 ..;Then check the transaction file for matching status.
50 ..Q:'$D(NAOU(PSD)) S PSDNA=$S($P($G(^PSD(58.8,+PSD,0)),"^")]"":$P(^(0),"^"),1:"ZZ/"_PSD)
51 ..S PSDOK=$S(STAT=3:"**",STAT=10:"*",1:""),PSDTR=$P(NODE,"^",17) I STAT=10 Q:$D(^PSD(58.81,"AE",PSDTR))
52 ..S PSDRN=$S($P($G(^PSDRUG(PSDR,0)),"^")]"":$P(^(0),"^"),1:"ZZ/"_PSDR),STAT1=+$P(NODE,"^",11),STATN=$S($P($G(^PSD(58.82,STAT1,0)),"^")]"":$P(^(0),"^"),1:"UNKNOWN")
53 ..S QTY=$P(NODE,"^",19),NUM=$S($P(NODE,"^",16)]"":$P(NODE,"^",16),1:"UNKNOWN"),EXP=$P(NODE,"^",10),EXPD="" I EXP S Y=EXP X ^DD("DD") S EXPD=Y
54 ..S PSDST=$P(NODE,"^",14),PSDDT="" I PSDST S Y=$E(PSDST,1,7) X ^DD("DD") S PSDDT=Y
55 ..D SET
56 Q
57SET ;sets ^tmp
58 S PSDCNT=PSDCNT+1
59 I ASKN D LOOP0 Q
60 S:ASK="D" ^TMP("PSDLOG",$J,PSDNA,PSDRN,NUM,PSDCNT)=QTY_"^"_PSDDT_"^"_EXPD_"^"_PSDOK
61 S:ASK="N" ^TMP("PSDLOG",$J,PSDNA,NUM,PSDRN,PSDCNT)=QTY_"^"_PSDDT_"^"_EXPD_"^"_PSDOK
62 Q
63LOOP0 ;sets sort for inventory type sort
64 I '$O(^PSD(58.8,PSD,1,PSDR,2,0)) S TYPN="ZZ** NO INVENTORY TYPE DATA **" D LOOP1 Q
65 ;F NAOU=0:0 S NAOU=$O(NAOU(NAOU)) Q:'NAOU
66 F TYP=0:0 S TYP=$O(^PSD(58.8,+PSD,1,PSDR,2,TYP)) Q:'TYP S TYPN=$S($P($G(^PSI(58.16,+TYP,0)),"^")]"":$P(^(0),"^"),1:"TYPE NAME MISSING") D LOOP1
67 Q
68LOOP1 ;S:ASK="D" ^TMP("PSDLOG",$J,PSDNA,TYPN,PSDRN,NUM,PSDCNT)=QTY_"^"_PSDDT_"^"_EXPD_"^"_PSDOK
69 S:'$G(TYP) TYP=999999
70 D:ASK="D"
71 .S ^TMP("PSDLOG",$J,"B",PSDNA,PSD)="",^TMP("PSDLOG",$J,PSD,+TYP)=0
72 .S ^TMP("PSDLOG",$J,PSD,"B",TYPN,+TYP)=""
73 .S ^TMP("PSDLOG",$J,PSD,+TYP,PSDR,NUM,PSDCNT)=QTY_U_PSDDT_U_EXPD_U_PSDOK
74 .S ^TMP("PSDLOG",$J,PSD,+TYP,"B",PSDRN,PSDR)=""
75 ;S:ASK="N" ^TMP("PSDLOG",$J,PSDNA,TYPN,NUM,PSDRN,PSDCNT)=QTY_"^"_PSDDT_"^"_EXPD_"^"_PSDOK
76 D:ASK="N"
77 .S ^TMP("PSDLOG",$J,"B",PSDNA,PSD)="",^TMP("PSDLOG",$J,PSD,+TYP)=0
78 .S ^TMP("PSDLOG",$J,PSD,"B",TYPN,+TYP)=""
79 .S ^TMP("PSDLOG",$J,PSD,+TYP,NUM,PSDR,PSDCNT)=QTY_U_PSDDT_U_EXPD_U_PSDOK_U_PSDRN
80 Q
Note: See TracBrowser for help on using the repository browser.