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

PSGWEDI.m

Go to the documentation of this file.
PSGWEDI ;BHAM ISC/GRK,CML-Enter/Edit of AOU Inventory Values ; 17 Jun 93 / 10:35 AM
 ;;2.3; Automatic Replenishment/Ward Stock ;;4 JAN 94
 I '$D(PSGWSITE) D ^PSGWSET Q:'$D(PSGWSITE)  S PSGWFLG=1
 I $P(PSGWSITE,"^",5) W !!?5,"You may not enter on-hand amounts because you have the ""Merge",!?5,"Inventory Sheet and Pick List"" site parameter set to ""YES""." Q
 S DIC="^PSI(58.19,",DIC(0)="QEAMNZ",DIC("A")="SELECT DATE/TIME FOR INVENTORY: " D ^DIC K DIC Q:Y<0  S PSGWIDA=+Y
 ;
EN1 ; PSGWIDA = DA of inventory being edited
 K PSGW("PO") S PSGWV="AMIS COMPILE FLAG"
 F SK=0:0 S SK=$O(^PSI(58.19,PSGWIDA,1,"C",SK)) Q:'SK  F J=0:0 S J=$O(^PSI(58.19,PSGWIDA,1,"C",SK,J)) Q:'J  S PSGW("PO",SK,J)=""
 S (PSGWADT,PSGWIN)=$P(^PSI(58.19,PSGWIDA,0),"^",1),PSGWCAT="A",FLG=0,AMISFL=0
WLOOP F PSGSORTK=0:0 S PSGSORTK=$O(PSGW("PO",PSGSORTK)) Q:'PSGSORTK  Q:FLG  F PSGDA=0:0 S PSGDA=$O(PSGW("PO",PSGSORTK,PSGDA)) Q:'PSGDA  D WENT Q:FLG  S AMISFL=0
END D CHKGLOB K PSGW("PO"),PSG1,PSG2,PSG3,PSGWACT,PSGWAOUN,PSGWDA,PSGDDA,PSGWDN,PSGDR,PSGWOD,PSGSORTK,PSGWIN,PSGWN,PSGX,PSGDA,PSGTYP,PSGWIDA,SK,WN,X,Y,I,J,K,L,M,MIN,N,P1,P2,P3,RELEV,TYP,DRUG,A,PSGWDRG,PSGWADT,PSGWCAT,PSGWQD,FLG,PSGWV,DIC
 K AMISFL,PSGWAOU,KEY,DA,K1,GRP,LP,PC,%,%Y,C K:$D(PSGWFLG) PSGWFLG,PSGWSITE Q
WENT S PSGWN=$S($D(^PSI(58.1,PSGDA,0)):$P(^(0),"^",1),1:""),DIC("B")=PSGWN
 W ! S DIC="^PSI(58.19,PSGWIDA,1,",DIC(0)="AEQNMZ" D ^DIC K DIC S (PSGWDA,DA,PSGWAOU)=+Y,PSGWAOUN=$P(Y,"^",2) S:Y<0 FLG=1 Q:Y<0  S:($P(^PSI(58.1,PSGWDA,0),"^",3)'=1)&($P(PSGWSITE,"^",25)=1) AMISFL=1
 S PSG1=""
PSG1 S PSG1=$O(^PSI(58.19,"AINV",PSGWIDA,PSGWDA,PSG1)) Q:PSG1=""  S PSG2=""
PSG2 S PSG2=$O(^PSI(58.19,"AINV",PSGWIDA,PSGWDA,PSG1,PSG2)) G PSG1:PSG2="" S PSG3=""
PSG3 S PSG3=$O(^PSI(58.19,"AINV",PSGWIDA,PSGWDA,PSG1,PSG2,PSG3)) G PSG2:PSG3="" S PSGTYP=""
PSGTYP S PSGTYP=$O(^PSI(58.19,"AINV",PSGWIDA,PSGWDA,PSG1,PSG2,PSG3,PSGTYP)) G PSG3:PSGTYP="" S PSGDR=""
PSGDR S PSGDR=$O(^PSI(58.19,"AINV",PSGWIDA,PSGWDA,PSG1,PSG2,PSG3,PSGTYP,PSGDR)) G PSGTYP:PSGDR="" S PSGDDA=+^(PSGDR),PSGWDN=$P(^(PSGDR),"^",2)
 W !!," ITEM: ",PSGDR
 I $D(^PSI(58.1,PSGWDA,1,PSGDDA,1,PSGWIDA,0)) S A=^(0)
 E  D EN3^PSGWEDI1
 F J=1:1:6 S PSGX(J)=$P(A,"^",J)
ONH W !,"ON-HAND: " W:PSGX(6)'="" PSGX(6),"//" R X:DTIME S:'$T FLG=1 Q:'$T  W:PSGX(6)=""&(X="") PSGX(2) S:X="" X=PSGX(6) Q:X="^"  S:X="" X=PSGX(2) I X["^" S PSGWDRG=X D EN1^PSGWEDI1 G:DA<0 ONH G PSGDR
 I "?"[$E(X)!(X<0)!(X>9999)!(X'?1N.N) W *7,!,"Enter quantity presently on-hand in the ward at the time of inventory.",!,"Must be a number between 0 and 9999." G ONH
 S PSGX(6)=$S(X="@":"",1:X),RELEV=$P(^PSI(58.1,PSGWDA,1,PSGDDA,0),"^",11),MIN=$P(^(0),"^",12) D DISP
DUMP S (PSGWOD,PSGWACT,PSGWQD)=PSGX(5) I (AMISFL=1)&(PSGWQD'=0) S ^PSI(58.5,"AMIS",$H,PSGWADT,PSGWCAT,PSGWAOU,PSGWDN,PSGWQD)=""
 S ^(PSGDR)=$P(^PSI(58.19,"AINV",PSGWIDA,PSGWDA,PSG1,PSG2,PSG3,PSGTYP,PSGDR),"^",1,3)_"^"_PSGX(5)
 S A="" F J=1:1:6 S A=A_PSGX(J)_"^"
 S ^(0)=A_$P(^PSI(58.1,PSGWDA,1,PSGDDA,1,PSGWIDA,0),"^",7,999)
 D:PSGX(5)'=0 ^PSGWFLBO G PSGDR
 ;
CHKGLOB ;Set piece 4 of global to 0 if null.
AOU S (P1,P2,P3,TYP,DRUG)=0 F I=0:0 S I=$O(^PSI(58.19,"AINV",PSGWIDA,I)) Q:'I  D P1
 Q
P1 F J=0:0 S P1=$O(^PSI(58.19,"AINV",PSGWIDA,I,P1)) Q:P1=""  D P2
 Q
P2 F K=0:0 S P2=$O(^PSI(58.19,"AINV",PSGWIDA,I,P1,P2)) Q:P2=""  D P3
 Q
P3 F L=0:0 S P3=$O(^PSI(58.19,"AINV",PSGWIDA,I,P1,P2,P3)) Q:P3=""  D TYP
 Q
TYP F M=0:0 S TYP=$O(^PSI(58.19,"AINV",PSGWIDA,I,P1,P2,P3,TYP)) Q:TYP=""  D DRUG
 Q
DRUG F N=0:0 S DRUG=$O(^PSI(58.19,"AINV",PSGWIDA,I,P1,P2,P3,TYP,DRUG)) Q:DRUG=""  I $P(^(DRUG),"^",4)="" S $P(^(DRUG),"^",4)=0
 Q
DISP ;CALCULATE DISPENSE AMT
 S PSGX(5)=PSGX(2)-PSGX(6) S:PSGX(5)<0 PSGX(5)=0 I RELEV']"" Q
 I PSGX(6)>+RELEV S PSGX(5)=0 Q
 I PSGX(5)<+MIN S PSGX(5)=+MIN
 Q