source: FOIAVistA/trunk/r/DRUG_ACCOUNTABILITY-PSA/PSAHIS.m@ 1397

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

initial load of FOIAVistA 6/30/08 version

File size: 4.1 KB
Line 
1PSAHIS ;BIR/LTL,JMB-Drug Transaction History ;7/23/97
2 ;;3.0; DRUG ACCOUNTABILITY/INVENTORY INTERFACE;**3,15**; 10/24/97
3 ;This routine prints a report of all or specific drugs in a pharmacy
4 ;location for a user-specified number of days.
5 ;
6 ;References to ^PSDRUG( are covered by IA #2095
7 ;
8LOC ;Gets locations & drugs to print
9 S (PSACNT,PSAOUT)=0 D ^PSAUTL3 G:PSAOUT EXIT1
10 S PSACNT=0,PSACHK=$O(PSALOC(""))
11 I PSACHK="",'PSALOC W !,"There are no active pharmacy locations." G EXIT1
12 W ! S PSALOCN="" F S PSALOCN=$O(PSALOC(PSALOCN)) Q:PSALOCN=""!(PSAOUT) S PSALOC=0 F S PSALOC=$O(PSALOC(PSALOCN,PSALOC)) Q:'PSALOC!(PSAOUT) D
13 .W @IOF W:$L(PSALOCN)>79 !,$P(PSALOCN,"(IP)",1)_"(IP)",!?17,$P(PSALOCN,"(IP)",2) W:$L(PSALOCN)<80 !,PSALOCN
14 .D DRUG Q:PSAOUT Q:X["^A"
15 G:PSAOUT EXIT G DAYS
16DRUG ;Gets drugs to print
17 W !!,"You may select one, several, or ^ALL drugs."
18 F S DIC="^PSD(58.8,"_+PSALOC_",1,",DIC(0)="AEMQ",DIC("A")="Select Drug: " D Q:PSAOUT!(Y<0)!(X["^A")
19 .D ^DIC K DIC I X'["^A"&(Y<1)&('PSACNT) S PSAOUT=1 Q
20 .I X["^A" D ALL^PSAHIS1 Q
21 .Q:Y<0 I $G(DTOUT)!($G(DUOUT)) S PSAOUT=1 Q
22 .S ^TMP("PSADRG",$J,PSALOC,$P($G(^PSDRUG(+Y,0)),"^"),+Y)="" S PSACNT=PSACNT+1
23 .I PSACNT=1,'$O(^PSD(58.81,"F",+$O(^TMP("PSADRG",$J,PSALOC,$P($G(^PSDRUG(+Y,0)),"^"),0)),0)) W !!,"There have been no transactions for this drug.",!
24 I '$D(PSALOC) W !!,"There are no drugs in all the selected location(s)." G EXIT
25 Q
26 ;
27DAYS G:$O(^TMP("PSADRG",$J,""))="" EXIT
28 S DIR(0)="D:AEP",DIR("A")="How many days back do you want to search for the drug: ",DIR("B")="T-6M",DIR("?")="I will list transactions for your selected drug(s) within the last six months if you press return" W ! D ^DIR K DIR
29 S PSABDT=Y G:$G(DIRUT) EXIT
30 ;
31DEV ;Asks device & queueing info
32 K IO("Q") N %ZIS,IOP,POP S %ZIS="Q" W !
33 D ^%ZIS I POP W !,"NO DEVICE SELECTED OR OUTPUT PRINTED!" Q
34 I $D(IO("Q")) D G EXIT
35 .N ZTDESC,ZTIO,ZTRTN,ZTSAVE,ZTDTH,ZTSK
36 .S ZTRTN="START^PSAHIS",ZTDESC="Drug Acct.-Drug Transaction History"
37 .S ZTSAVE("PSALOC(")="",ZTSAVE("PSABDT")="",ZTSAVE("^TMP(""PSADRG"",$J,")="" D ^%ZTLOAD
38 ;
39START ;Compiles & prints output data
40 S PSARPDT=$E($$HTFM^XLFDT($H),1,12),PSADT=$P(PSARPDT,"."),PSATM=$P(PSARPDT,".",2)
41 S PSARPDT=$E(PSADT,4,5)_"-"_$E(PSADT,6,7)_"-"_$E(PSADT,2,3),PSARUN=PSARPDT_"@"_PSATM
42 S PSADLN="=====================================|==========|=====|=====|==========|========"
43 S PSABDTR=$E(PSABDT,4,5)_"-"_$E(PSABDT,6,7)_"-"_$E(PSABDT,2,3),PSAOUT=0
44 S PSALOCN="" F S PSALOCN=$O(PSALOC(PSALOCN)) Q:PSALOCN="" D G:PSAOUT EXIT
45 .S PSALOC=0 F S PSALOC=$O(PSALOC(PSALOCN,PSALOC)) Q:'PSALOC D SITES^PSAUTL1,FIND Q:PSAOUT
46 ;
47EXIT W:$E(IOST,1,2)="C-" @IOF D ^%ZISC S:$D(ZTQUEUED) ZTREQ="@"
48 K IO("Q"),^TMP("PSA",$J),^TMP("PSADRG",$J),^TMP("PSAHIS",$J),PSALOC,PSALOCA,PSALOCN
49 ;G:'PSAOUT LOC
50EXIT1 K %ZIS,DIC,DIR,DIRUT,DTOUT,DUOUT,PSA50,PSABAD,PSABAD1,PSABAL,PSABDT,PSABDTR,PSACHK,PSACNT,PSACOMB,PSADJT,PSADJDT,PSADLN,PSADRG,PSADRUG,PSADT
51 K PSAFIRST,PSAHOLD,PSAHOLDN,PSAIPT,PSAISIT,PSAISITN,PSALN,PSALOC,PSALOCA,PSALOCN,PSANONE,PSAOPT,PSAOSIT,PSAOSITN,PSAOUT,PSAPC,PSAPC1,PSAPCS,PSAPG
52 K PSAREA,PSARECT,PSARPDT,PSARPDT,PSARUN,PSAS,PSASEL,PSASITES,PSASS,PSATM,PSATR,PSATR0,PSATRANL,PSATRCNT,PSAWRT,X,Y,ZTDESC,ZTDTH,ZTIO,ZTRTN,ZTSAVE,ZTSK
53 Q
54FIND ;Finds drugs & puts in alpha order in ^TMP("PSAHIS",$J)
55 K ^TMP("PSAHIS",$J),^TMP("PSA",$J),PSAFIRST
56 S (PSACNT,PSAPG)=0,PSADRG=""
57 F S PSADRG=$O(^TMP("PSADRG",$J,PSALOC,PSADRG)) Q:PSADRG="" S (PSABAD,PSA50)=0 F S PSA50=$O(^TMP("PSADRG",$J,PSALOC,PSADRG,PSA50)) Q:'PSA50 D
58 .;I '$G(PSATR),$O(^TMP("PSADRG",$J,PSALOC,PSADRG,0)) S PSA50=$O(^TMP("PSADRG",$J,PSALOC,PSADRG,0))
59 .S (PSAFIRST,PSATR)=0 F S PSATR=+$O(^PSD(58.81,"F",PSA50,PSATR)) Q:'PSATR!(PSAOUT) D Q:PSAOUT
60 ..S PSATR0=$G(^PSD(58.81,PSATR,0)) Q:$P(PSATR0,"^",3)'=PSALOC
61 ..I $P(PSATR0,"^",4)'<PSABDT S ^TMP("PSAHIS",$J,PSADRG,$E($P(PSATR0,"^",4),1,7),PSATR)="" S:'PSAFIRST PSAFIRST=PSATR,^TMP("PSA",$J,PSADRG)=PSATR Q
62 ..I PSAFIRST,PSATR>PSAFIRST S PSABAD1=$S($P(PSATR0,"^",2)=2!($P(PSATR0,"^",2)=15)!($P(PSATR0,"^",2)=6):-$P(PSATR0,"^",6),1:$P(PSATR0,"^",6)) S PSABAD(PSADRG)=$G(PSABAD(PSADRG))+PSABAD1
63 I $D(^TMP("PSAHIS",$J)) D ^PSAHIS1 Q
64 I '$D(^TMP("PSAHIS",$J)) W !!,"No transactions were found for the pharmacy location." H 1
65 Q
Note: See TracBrowser for help on using the repository browser.