source: WorldVistAEHR/trunk/r/CONTROLLED_SUBSTANCES-PSD/PSDADJC.m@ 1608

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

initial load of WorldVistAEHR

File size: 4.2 KB
Line 
1PSDADJC ;B'ham ISC/LTL,JPW - Balance Shift Checker for NAOU ; 16 Feb 94
2 ;;3.0; CONTROLLED SUBSTANCES ;**53,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,PSDOUT,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 W ! D ^DIC K DIC G:$D(DTOUT)!($D(DUOUT))!(Y<1) QUIT
7 ;VMP OIFO BAY PINES;VGF;PSD*3.0*53;ADDED SET OF VARIABLE NAOU
8 S (NAOU,PSDLOC)=+Y,(NAOUN,PSDLOCN)=$P(Y,U,2),PSDS=+$P(Y(0),"^",4)
9 I '+$P($G(^PSD(58.8,PSDLOC,2)),"^",5) W !!,"This NAOU does not maintain a perpetual inventory balance to check.",!! K PSDLOC,PSDLOCN,PSDS G LOOK
10CHKD I '$O(^PSD(58.8,PSDLOC,1,0)) W !!,"There are no drugs in ",PSDLOCN G QUIT
11WIT W ! S NUR2=$$WITNESS^XUVERIFY("WITNESS")
12 I NUR2=DUZ W !!,"Wait a second, you can't witness yourself!",$C(7) G WIT
13 G:NUR2'>0 QUIT
14 W !!,"Thank you, ",$S($P($G(^VA(200,NUR2,.1)),U,4)]"":$P($G(^(.1)),U,4),1:$P($G(^VA(200,NUR2,0)),U))
15 W !!,"Give me a second to alphabetize.",!
16 S PSDRUG=0,PSDRUGN=""
17 F S PSDRUG=$O(^PSD(58.8,PSDLOC,1,PSDRUG)) Q:'PSDRUG D
18 .Q:'$D(^PSD(58.8,+PSDLOC,1,+PSDRUG,0))!($P($G(^PSDRUG(+PSDRUG,0)),"^")']"")!('$P($G(^PSD(58.8,+PSDLOC,1,PSDRUG,0)),U,4))
19 .S PSDPKG=$P($G(^PSD(58.8,+PSDS,1,+PSDRUG,0)),"^",9),PSDBKU=$P($G(^(0)),"^",8)
20 .S ^TMP("PSDB",$J,$P($G(^PSDRUG(+PSDRUG,0)),U),PSDRUG)=PSDPKG_"^"_PSDBKU K Y
21 W @IOF S (PSDRUG,PSDRUGN)=0
22 F S PSDRUGN=$O(^TMP("PSDB",$J,PSDRUGN)) Q:PSDRUGN']"" F S PSDRUG=$O(^TMP("PSDB",$J,PSDRUGN,PSDRUG)) Q:'PSDRUG D G:$D(DIRUT)!($G(PSDOUT)) QUIT
23 .Q:'$G(^PSD(58.8,PSDLOC,1,PSDRUG,0))
24 .S NODE=$G(^TMP("PSDB",$J,PSDRUGN,PSDRUG))
25BAL .W !!,PSDRUGN,!!,"Balance: "
26 .S (PSDREC,PSDREC(1),PSDREC(2))=$P($G(^PSD(58.8,PSDLOC,1,PSDRUG,0)),U,4)
27 .W PSDREC," ",$P(NODE,U,2)
28 .S DIR(0)="Y",DIR("A")="Count Correct",DIR("B")="Yes"
29 .W ! D ^DIR K DIR Q:$D(DIRUT)
30 .G:Y=1 INV
31 .F L +^PSD(58.8,+PSDLOC,1,+PSDRUG,0):$S($G(DILOCKTM)>0:DILOCKTM,1:3) I Q
32 .S PSDREC(1)=$P($G(^PSD(58.8,PSDLOC,1,PSDRUG,0)),U,4)
33 .D NOW^%DTC S PSDAT=+%
34 .W !!,"Package Size: ",$P($G(NODE),"^")," Breakdown Unit: ",$P($G(NODE),"^",2),!
35 .S DIR(0)="NA^0:999999:2",DIR("A")="Correct Count: "
36 .S DIR("B")=PSDREC D ^DIR K DIR Q:$D(DIRUT) S PSDREC(1)=Y
37 .I Y=PSDREC W !!,"That's no change." G INV
38 .I Y>PSDREC S NAOU(1)=0 D ^PSDORSU G:$G(NAOU(1)) BAL I $G(PSDOUT) L -^PSD(58.8,+PSDLOC,1,+PSDRUG,0) Q
39 .S DIR(0)="58.81,15" W ! D ^DIR K DIR Q:$D(DIRUT) S PSDRE=Y
40 .S DIE="^PSD(58.8,+PSDLOC,1,",DA(1)=PSDLOC,DA=PSDRUG
41 .S DR="3////"_$G(PSDREC(1)) D ^DIE
42 .S $P(^PSD(58.8,PSDLOC,1,PSDRUG,0),"^",17)=1
43 .L -^PSD(58.8,+PSDLOC,1,+PSDRUG,0)
44INV .I '$G(PSDAT) D NOW^%DTC S PSDAT=%
45 .S PSDREC=$G(PSDREC(1))-PSDREC G:'PSDREC TRA
46MON .S:'$D(^PSD(58.8,+PSDLOC,1,+PSDRUG,5,0)) ^(0)="^58.801A^^"
47 .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
48 .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
49TRA .W !!,"Recording ",$S(PSDREC:"adjustment",1:"inventory")," in transaction history.",!
50TR .F L +^PSD(58.81,0):$S($G(DILOCKTM)>0:DILOCKTM,1:3) I Q
51FIND .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
52 .S DIC="^PSD(58.81,",DIC(0)="L",DLAYGO=58.81,(DINUM,X)=PSDT D ^DIC K DIC,DLAYGO L -^PSD(58.81,0)
53 .S DIE="^PSD(58.81,",DA=PSDT,DR="1////"_$S(PSDREC:9,1:23)_";2////"_PSDLOC_";3////"_PSDAT_";4////"_PSDRUG_";5////"_PSDREC_";6////"_DUZ_";9////"_PSDREC(2)_";15////"_$G(PSDRE)_";74////"_DUZ_";78////"_NUR2_";100////1" D ^DIE K DIE
54 .S:'$D(^PSD(58.8,+PSDLOC,1,+PSDRUG,4,0)) ^(0)="^58.800119PA^^"
55 .S DIC="^PSD(58.8,+PSDLOC,1,+PSDRUG,4,",DIC(0)="L",DLAYGO=58.8
56 .S (X,DINUM)=PSDT,DA(2)=PSDLOC,DA(1)=PSDRUG D ^DIC K DIC,DA,DLAYGO,Y
57 .S NAOU=PSDLOC,NAOUN=PSDLOCN
58MM .I PSDREC S PHARM1=DUZ,PSDT=PSDAT,PSDR=PSDRUG,PSDRE=$G(PSDRE),QTY=-PSDREC D ^PSDRFM
59REP S DIR(0)="Y",DIR("A")="Would you like a report of current balances"
60 S DIR("B")="No" D ^DIR K DIR D:Y=1 DEV^PSDBAN
61QUIT K ^TMP("PSDB",$J) Q
Note: See TracBrowser for help on using the repository browser.