Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: PSAHIS

PSAHIS.m

Go to the documentation of this file.
  1. PSAHIS ;BIR/LTL,JMB-Drug Transaction History ;7/23/97
  1. ;;3.0;DRUG ACCOUNTABILITY/INVENTORY INTERFACE;**3,15,73**; 10/24/97;Build 3
  1. ;This routine prints a report of all or specific drugs in a pharmacy
  1. ;location for a user-specified number of days.
  1. ;
  1. ;References to ^PSDRUG( are covered by IA #2095
  1. ;
  1. LOC ;Gets locations & drugs to print
  1. S (PSACNT,PSAOUT)=0 D ^PSAUTL3 G:PSAOUT EXIT1
  1. S PSACNT=0,PSACHK=$O(PSALOC(""))
  1. I PSACHK="",'PSALOC W !,"There are no active pharmacy locations." G EXIT1
  1. 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
  1. .W @IOF W:$L(PSALOCN)>79 !,$P(PSALOCN,"(IP)",1)_"(IP)",!?17,$P(PSALOCN,"(IP)",2) W:$L(PSALOCN)<80 !,PSALOCN
  1. .D DRUG Q:PSAOUT Q:X["^A"
  1. G:PSAOUT EXIT G DAYS
  1. DRUG ;Gets drugs to print
  1. W !!,"You may select one, several, or ^ALL drugs."
  1. F S DIC="^PSD(58.8,"_+PSALOC_",1,",DIC(0)="AEMQ",DIC("A")="Select Drug: " D Q:PSAOUT!(Y<0)!(X["^A")
  1. .D ^DIC K DIC I X'["^A"&(Y<1)&('PSACNT) S PSAOUT=1 Q
  1. .I X["^A" D ALL^PSAHIS1 Q
  1. .Q:Y<0 I $G(DTOUT)!($G(DUOUT)) S PSAOUT=1 Q
  1. .S ^TMP("PSADRG",$J,PSALOC,$P($G(^PSDRUG(+Y,0)),"^"),+Y)="" S PSACNT=PSACNT+1
  1. .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.",!
  1. I '$D(PSALOC) W !!,"There are no drugs in all the selected location(s)." G EXIT
  1. Q
  1. ;
  1. DAYS G:$O(^TMP("PSADRG",$J,""))="" EXIT
  1. 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
  1. S PSABDT=Y G:$G(DIRUT) EXIT
  1. ;
  1. DEV ;Asks device & queueing info
  1. K IO("Q") N %ZIS,IOP,POP S %ZIS="Q" W !
  1. D ^%ZIS I POP W !,"NO DEVICE SELECTED OR OUTPUT PRINTED!" G EXIT ;;<*73 - RJS
  1. I $D(IO("Q")) D G EXIT
  1. .N ZTDESC,ZTIO,ZTRTN,ZTSAVE,ZTDTH,ZTSK
  1. .S ZTRTN="START^PSAHIS",ZTDESC="Drug Acct.-Drug Transaction History"
  1. .S ZTSAVE("PSALOC(")="",ZTSAVE("PSABDT")="",ZTSAVE("^TMP(""PSADRG"",$J,")="" D ^%ZTLOAD
  1. ;
  1. START ;Compiles & prints output data
  1. S PSARPDT=$E($$HTFM^XLFDT($H),1,12),PSADT=$P(PSARPDT,"."),PSATM=$P(PSARPDT,".",2)
  1. S PSARPDT=$E(PSADT,4,5)_"-"_$E(PSADT,6,7)_"-"_$E(PSADT,2,3),PSARUN=PSARPDT_"@"_PSATM
  1. S PSADLN="=====================================|==========|=====|=====|==========|========"
  1. S PSABDTR=$E(PSABDT,4,5)_"-"_$E(PSABDT,6,7)_"-"_$E(PSABDT,2,3),PSAOUT=0
  1. S PSALOCN="" F S PSALOCN=$O(PSALOC(PSALOCN)) Q:PSALOCN="" D G:PSAOUT EXIT
  1. .S PSALOC=0 F S PSALOC=$O(PSALOC(PSALOCN,PSALOC)) Q:'PSALOC D SITES^PSAUTL1,FIND Q:PSAOUT
  1. ;
  1. EXIT W:$E(IOST,1,2)="C-" @IOF D ^%ZISC S:$D(ZTQUEUED) ZTREQ="@"
  1. K IO("Q"),^TMP("PSA",$J),^TMP("PSADRG",$J),^TMP("PSAHIS",$J),PSALOC,PSALOCA,PSALOCN
  1. ;G:'PSAOUT LOC
  1. EXIT1 K %ZIS,DIC,DIR,DIRUT,DTOUT,DUOUT,PSA50,PSABAD,PSABAD1,PSABAL,PSABDT,PSABDTR,PSACHK,PSACNT,PSACOMB,PSADJT,PSADJDT,PSADLN,PSADRG,PSADRUG,PSADT
  1. K PSAFIRST,PSAHOLD,PSAHOLDN,PSAIPT,PSAISIT,PSAISITN,PSALN,PSALOC,PSALOCA,PSALOCN,PSANONE,PSAOPT,PSAOSIT,PSAOSITN,PSAOUT,PSAPC,PSAPC1,PSAPCS,PSAPG
  1. K PSAREA,PSARECT,PSARPDT,PSARPDT,PSARUN,PSAS,PSASEL,PSASITES,PSASS,PSATM,PSATR,PSATR0,PSATRANL,PSATRCNT,PSAWRT,X,Y,ZTDESC,ZTDTH,ZTIO,ZTRTN,ZTSAVE,ZTSK
  1. Q
  1. FIND ;Finds drugs & puts in alpha order in ^TMP("PSAHIS",$J)
  1. K ^TMP("PSAHIS",$J),^TMP("PSA",$J),PSAFIRST
  1. S (PSACNT,PSAPG)=0,PSADRG=""
  1. 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
  1. .;I '$G(PSATR),$O(^TMP("PSADRG",$J,PSALOC,PSADRG,0)) S PSA50=$O(^TMP("PSADRG",$J,PSALOC,PSADRG,0))
  1. .S (PSAFIRST,PSATR)=0 F S PSATR=+$O(^PSD(58.81,"F",PSA50,PSATR)) Q:'PSATR!(PSAOUT) D Q:PSAOUT
  1. ..S PSATR0=$G(^PSD(58.81,PSATR,0)) Q:$P(PSATR0,"^",3)'=PSALOC
  1. ..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
  1. ..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
  1. I $D(^TMP("PSAHIS",$J)) D ^PSAHIS1 Q
  1. I '$D(^TMP("PSAHIS",$J)) W !!,"No transactions were found for the pharmacy location." H 1
  1. Q