source: WorldVistAEHR/trunk/r/CONTROLLED_SUBSTANCES-PSD/PSDNMBA.m@ 1306

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

initial load of WorldVistAEHR

File size: 4.1 KB
Line 
1PSDNMBA ;DOIFO/CMS - CSM Balance Adjustments ;18 Dec 02
2 ;;3.0; CONTROLLED SUBSTANCES ;*41*;13 Feb 97
3 ;Reference to ^PSD(58.81 supported by IA #2808
4 ;Reference to ^PSDRUG( supported by IA #221
5 ;Reference to ^PSD(58.84 supported by IA #3485
6 Q
7 ;
8ST ;CS Monitoring OPTION ENTRY
9 N PSDA,PSDIDIV,PSDPLOC,PSDCII,PSDED,PSDOUT,PSDDTN,PSDSD,PSDSITE,X,Y,%
10 N DIC,DIR,DIRUT,DIROUT,DTOUT,DUOUT,POP,ZTIO,ZTSAVE,ZTSK,ZTRTN,ZTDESC,%ZIS
11 W !!,?5,"This report lists Drug Accountability Balance Adjustments"
12 W !,?5,"made for the Inpatient Site Pharmacy Location(s) entered.",!!
13 S PSDA=$O(^PSD(58.84,"B","BALANCE ADJUSTMENT",0))
14 I 'PSDA W !!,"<< Drug Accountability Transaction Type, Balance Adjustment, not defined! >>" G END
15 D INPS^PSDNMU I '$G(PSDIDIV)!($G(PSDOUT)) G END
16 W ! S DIR("A")="Select 'ALL' "_$P(PSDIDIV,U,2)_" Pharmacy locations"
17 S DIR("B")="Yes",DIR(0)="Y" D ^DIR I X="^"!($D(DTOUT)) G END
18 I Y'=1 W ! D PLOC^PSDNMU I '$O(PSDPLOC(0))!($G(PSDOUT)) G END
19 I Y=1 D PLOCA^PSDNMU
20 ;
21 S PSDDTN="Balance Adjustment" D DATE^PSDNMU I '$G(PSDSD)!($G(PSDOUT)) G END
22 W ! K DIR S DIR("A")="Okay to Continue",DIR("B")="No",DIR(0)="Y" D ^DIR
23 I Y'=1 W " <No report>",! G END
24 W !!,?9,"This report should be queued to run during non-peak hours.",!
25 K IO("Q") S %ZIS="MQ" D ^%ZIS I POP W " <No device selected.>" G END
26 I $D(IO("Q")) D
27 .S ZTRTN="DQ^PSDNMBA",ZTDESC="CS Monitoring - PSDNMBA"
28 .S ZTSAVE("PSDSD")="",ZTSAVE("PSDPLOC(")="",ZTSAVE("PSDED")="",ZTSAVE("PSDIDIV")=""
29 .D ^%ZTLOAD W !!?5,"TASK #",$G(ZTSK)," QUEUED!",!
30 I '$D(IO("Q")) U IO D DQ
31 K IOP,IO("Q")
32END Q
33 ;
34HD ;Report heading
35 N PSDY,X,Y,%
36 W @IOF,$$CJ^XLFSTR("CS Monitoring - Balance Adjustments Report",IOM)
37 S PSDY="Inpatient site: "_$P(PSDIDIV,U,2)
38 I $G(PSDPLOC)="^ALL" S PSDY=PSDY_" all Pharmacy Locations"
39 W !,$$CJ^XLFSTR(PSDY,IOM)
40 W !,$$CJ^XLFSTR("Balance Adjustments made: "_$P(PSDSD,U,2)_" thru "_$P(PSDED,U,2),IOM)
41 S PSDPG=PSDPG+1
42 D NOW^%DTC W !,"Report Run: "_$E($$FMTE^XLFDT(%),1,18),?70,"PAGE: ",PSDPG
43 W !,$$REPEAT^XLFSTR("=",IOM)
44 QUIT
45 ;
46DQ ;Report Run
47 N DFN,PSDA,PSDFD,PSDI,PSDIDT,PSDIV,PSDOUT,PSDP,PSDPG,PSDS,PSDRG,PSDUZ
48 N PSDX,PSDX0,PSDX2,PSDXOR1,PSDY,X,Y,%
49 K ^TMP("PSDNMBA",$J)
50 I IOST?1"C-".E W !!,?10,"Compiling report, please wait ..."
51 S PSDA=$O(^PSD(58.84,"B","BALANCE ADJUSTMENT",0)) I 'PSDA G DQQ
52 S PSDP=0
53 F S PSDP=$O(PSDPLOC(PSDP)) Q:'PSDP S ^TMP("PSDNMBA",$J,PSDPLOC(PSDP))=""
54 S PSDFD=+PSDSD
55 F S PSDFD=$O(^PSD(58.81,"AF",PSDFD)) Q:('PSDFD)!(PSDFD]+PSDED) D
56 . S PSDP=0
57 . F S PSDP=$O(PSDPLOC(PSDP)) Q:'PSDP D
58 . . S PSDX=0
59 . . F S PSDX=$O(^PSD(58.81,"AF",PSDFD,PSDP,PSDA,PSDX)) Q:'PSDX D
60 . . . S PSDX0=$G(^PSD(58.81,PSDX,0)) I PSDX0']"" Q
61 . . . S PSDRG=$G(^PSDRUG(+$P(PSDX0,U,5),0))
62 . . . S PSDUZ=+$P(PSDX0,U,7),PSDUZ=$P($G(^VA(200,+PSDUZ,0)),U,1)
63 . . . S Y=PSDFD D D^DIQ S PSDS=Y
64 . . . S ^TMP("PSDNMBA",$J,PSDPLOC(PSDP),PSDUZ,PSDX)=$P(PSDX0,U,1)_U_$E(PSDS,1,18)_U_$P(PSDX0,U,6)_U_$P(PSDRG,U,1)_U_$P(PSDX0,U,16)
65 ;
66PRT ;Report print
67 S PSDPG=0,PSDOUT=0
68 I '$D(^TMP("PSDNMBA",$J)) D G DQQ
69 . S PSDIV="",PSDPG=1 D HD,PHD
70 . W !!,?10,"<<<< NO DATA FOUND >>>>",!
71 S PSDIV=""
72 D HD,PHD
73 F S PSDIV=$O(^TMP("PSDNMBA",$J,PSDIV)) Q:(PSDIV="")!(PSDOUT) D
74 . I ($Y+3)>IOSL D PAGE Q:PSDOUT D HD,PHD
75 . W !!,"Pharmacy Location: ",PSDIV
76 . S PSDS=""
77 . I $O(^TMP("PSDNMBA",$J,PSDIV,PSDS))']"" W !,?19,"NO DATA FOUND" Q
78 . F S PSDS=$O(^TMP("PSDNMBA",$J,PSDIV,PSDS)) Q:(PSDS="")!(PSDOUT) D
79 . . I ($Y+3)>IOSL D PAGE Q:PSDOUT D HD,PHD
80 . . W !!,"TRANSACTOR: ",PSDS
81 . . S PSDX=0
82 . . F S PSDX=$O(^TMP("PSDNMBA",$J,PSDIV,PSDS,PSDX)) Q:('PSDX)!(PSDOUT) D
83 . . . S PSDY=$G(^TMP("PSDNMBA",$J,PSDIV,PSDS,PSDX))
84 . . . I ($Y+3)>IOSL D PAGE Q:PSDOUT D HD,PHD
85 . . . W !,$P(PSDY,U,1),?10,$P(PSDY,U,2),?33,$P(PSDY,U,3),?40,$P(PSDY,U,4)
86 . . . W !,?10,"Reason: ",$P(PSDY,U,5)
87 ;
88DQQ W ! K PSDCII,PSDIDIV,PSDPLOC,PSDSD,PSDED,^TMP("PSDNMBA",$J) D ^%ZISC Q
89 ;
90PHD ;
91 W !,"Trans. #",?10,"Date",?28,"Quantity",?40,"Drug"
92 W !,$$REPEAT^XLFSTR("_",IOM)
93 Q
94PAGE ;
95 N DIR,DIRUT,DTOUT,DUOUT,X,Y
96 I IOST?1"C-".E S DIR(0)="E" D ^DIR W !
97 I ($D(DTOUT))!($D(DIRUT)) S PSDOUT=1 Q:$G(PSDOUT)=1
98 Q
99 ;
100EOR ;PSDNMBA - CSM Balance Adjustments; 18 DEC 02
Note: See TracBrowser for help on using the repository browser.