source: FOIAVistA/trunk/r/CONTROLLED_SUBSTANCES-PSD/PSDADJIN.m@ 812

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

initial load of FOIAVistA 6/30/08 version

File size: 3.4 KB
Line 
1PSDADJIN ;B'ham ISC/LTL,JPW - Balance Initializer for NAOU ; 16 Feb 94
2 ;;3.0; CONTROLLED SUBSTANCES ;**66**;13 Feb 97;Build 3
3 I '$D(PSDSITE) D ^PSDSET G:'$D(PSDSITE) QUIT
4 N D1,D2,DIC,DIE,DINUM,D0,D1,DLAYGO,DR,DIR,DIRUT,DTOUT,DUOUT,NODE,PSAC,PSDAT,PSDLOC,PSDLOCN,DA,PSDRUG,PSDRUGN,PSDS,PSDPKG,PSDBKU,PSAQ,PSDR,PSDREC,PSDT,X,Y,%,%H,%I
5LOOK S DIC="^PSD(58.8,",DIC(0)="AEMQZ",DIC("A")="Select NAOU: ",DIC("S")="I $P($G(^(0)),U,3)=+PSDSITE,$P($G(^(0)),U,2)[""N"",'$P(^(0),""^"",7),$S('$D(^(""I"")):1,+^(""I"")>DT:1,'^(""I""):1,1:0)"
6 D ^DIC K DIC G:$D(DTOUT)!($D(DUOUT))!(Y<1) QUIT S PSDLOC=+Y,PSDLOCN=$P(Y,U,2),PSDS=+$P(Y(0),"^",4)
7 I '+$P($G(^PSD(58.8,PSDLOC,2)),"^",5) W !!,"This NAOU does not maintain a perpetual inventory balance to initialize.",!! K PSDLOC,PSDLOCN,PSDS G LOOK
8CHKD I '$O(^PSD(58.8,PSDLOC,1,0)) W !!,"There are no drugs in ",PSDLOCN G QUIT
9 S DIR(0)="Y",DIR("A",1)="This option will set all balances to zero before initializing.",DIR("A")="Are you sure you want to proceed"
10 D ^DIR K DIR G:Y'=1 QUIT
11 W !!,"Give me a second to alphabetize.",!
12 S PSDRUG=0,PSDRUGN=""
13 F S PSDRUG=$O(^PSD(58.8,PSDLOC,1,PSDRUG)) Q:'PSDRUG D
14 .Q:'$D(^PSD(58.8,+PSDLOC,1,+PSDRUG,0))!($P($G(^PSDRUG(+PSDRUG,0)),"^")']"")
15 .S PSDPKG=$P($G(^PSD(58.8,+PSDS,1,+PSDRUG,0)),"^",9),PSDBKU=$P($G(^(0)),"^",8)
16 .S ^TMP("PSDB",$J,$P($G(^PSDRUG(+PSDRUG,0)),U),PSDRUG)=PSDPKG_"^"_PSDBKU,$P(^PSD(58.8,+PSDLOC,1,+PSDRUG,0),U,4)=0 K Y
17 W @IOF
18 F PSAC=1:1 S PSDRUGN=$O(^TMP("PSDB",$J,PSDRUGN)) Q:PSDRUGN']"" S PSDRUG=$O(^TMP("PSDB",$J,PSDRUGN,0)) D G:$D(DIRUT) QUIT
19 .Q:'$G(^PSD(58.8,PSDLOC,1,PSDRUG,0))
20 .;S (PSD,PSD(1))=0
21 .;F S PSD=$O(^PSD(58.81,"AD",4,+PSDLOC,PSD)) S:$P($G(^PSD(58.81,+PSD,0)),U,5)=PSDRUG PSD(1)=1 Q:$G(PSD(1))!('PSD)
22 .;Q:'$G(PSD(1))
23 .S NODE=$G(^TMP("PSDB",$J,PSDRUGN,PSDRUG))
24 .S DIE="^PSD(58.8,+PSDLOC,1,",DA(1)=PSDLOC,DA=PSDRUG
25 .F L +^PSD(58.8,+PSDLOC,1,+PSDRUG,0):$S($G(DILOCKTM)>0:DILOCKTM,1:3) I Q
26 .D NOW^%DTC S PSDAT=+%
27 .W !!,PSDRUGN,!!,"Package Size: ",$P($G(NODE),"^")," Breakdown Unit: ",$P($G(NODE),"^",2),!
28 .S DIR(0)="NA^0:999999:2",DIR("A")="Initial Balance: " D ^DIR K DIR
29 .Q:$D(DIRUT) S PSDREC=Y
30 .S DR="3////"_PSDREC D ^DIE
31 .S $P(^PSD(58.8,PSDLOC,1,PSDRUG,0),"^",17)=1
32 .L -^PSD(58.8,+PSDLOC,1,+PSDRUG,0)
33 .Q:$G(PSDREC)']""
34MON .S:'$D(^PSD(58.8,+PSDLOC,1,+PSDRUG,5,0)) ^(0)="^58.801A^^"
35 .I '$D(^PSD(58.8,+PSDLOC,1,+PSDRUG,5,$E(DT,1,5)*100,0)) S DIC="^PSD(58.8,+PSDLOC,1,+PSDRUG,5,",DIC(0)="LM",DLAYGO=58.8,(X,DINUM)=$E(DT,1,5)*100,DA(2)=PSDLOC,DA(1)=PSDRUG D ^DIC K DIC,DLAYGO
36 .S DIE="^PSD(58.8,+PSDLOC,1,+PSDRUG,5,",DA(2)=PSDLOC,DA(1)=PSDRUG,DA=$E(DT,1,5)*100,DR="1////0;7////^S X=PSDREC" D ^DIE
37 .W !!,"Updating beginning balance and transaction history.",!
38TR .F L +^PSD(58.81,0):$S($G(DILOCKTM)>0:DILOCKTM,1:3) I Q
39FIND .S PSDT=$P(^PSD(58.81,0),U,3)+1 I $D(^PSD(58.81,PSDT)) S $P(^PSD(58.81,0),U,3)=$P(^PSD(58.81,0),U,3)+1 G FIND
40 .S DIC="^PSD(58.81,",DIC(0)="L",DLAYGO=58.81,(DINUM,X)=PSDT D ^DIC K DIC,DLAYGO L -^PSD(58.81,0)
41 .S DIE="^PSD(58.81,",DA=PSDT,DR="1////11;2////^S X=PSDLOC;3////^S X=PSDAT;4////^S X=PSDRUG;5////^S X=PSDREC;6////^S X=DUZ;9////0;100////1" D ^DIE K DIE
42 .S:'$D(^PSD(58.8,+PSDLOC,1,+PSDRUG,4,0)) ^(0)="^58.800119PA^^"
43 .S DIC="^PSD(58.8,+PSDLOC,1,+PSDRUG,4,",DIC(0)="L",DLAYGO=58.8
44 .S (X,DINUM)=PSDT,DA(2)=PSDLOC,DA(1)=PSDRUG D ^DIC K DIC,DA,DLAYGO,Y
45REP S DIR(0)="Y",DIR("A")="Would you like a report of current balances"
46 S DIR("B")="Yes" D ^DIR K DIR D:Y=1
47 .S NAOU=PSDLOC,NAOUN=PSDLOCN D DEV^PSDBAN
48QUIT K ^TMP("PSDB",$J) Q
Note: See TracBrowser for help on using the repository browser.